Skip to content

Commit 1b3adcc

Browse files
authored
Allow user providing non offical AWS region with custom endpoint (#706)
* Allow user provising non offical AWS region with custom endpoint * Add changelog entry
1 parent fcd674b commit 1b3adcc

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## NOT RELEASED
44

5+
### Fixed
6+
7+
- Allows non-AWS regions when using custom endpoints
8+
59
## 1.2.0
610

711
### Added

src/AbstractApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ protected function getEndpoint(string $uri, array $query, ?string $region): stri
193193
{
194194
/** @var string $region */
195195
$region = $region ?? $this->configuration->isDefault('region') ? null : $this->configuration->get('region');
196-
$metadata = $this->getEndpointMetadata($region);
197196
if (!$this->configuration->isDefault('endpoint')) {
198197
/** @var string $endpoint */
199198
$endpoint = $this->configuration->get('endpoint');
200199
} else {
200+
$metadata = $this->getEndpointMetadata($region);
201201
$endpoint = $metadata['endpoint'];
202202
}
203203

tests/Integration/StsClientTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\Core\Tests\Integration;
44

55
use AsyncAws\Core\Credentials\NullProvider;
6+
use AsyncAws\Core\Exception\UnsupportedRegion;
67
use AsyncAws\Core\Sts\Input\AssumeRoleRequest;
78
use AsyncAws\Core\Sts\Input\AssumeRoleWithWebIdentityRequest;
89
use AsyncAws\Core\Sts\Input\GetCallerIdentityRequest;
@@ -86,6 +87,25 @@ public function testGetCallerIdentity(): void
8687
self::assertStringContainsString('change it', $result->getArn());
8788
}
8889

90+
public function testNonAwsRegionWithCustomEndpoint(): void
91+
{
92+
$client = new StsClient([
93+
'endpoint' => 'http://localhost',
94+
'region' => 'test',
95+
], new NullProvider());
96+
self::assertNotEmpty($client->presign(new AssumeRoleRequest(['RoleArn' => 'demo', 'RoleSessionName' => 'demo'])));
97+
}
98+
99+
public function testNonAwsRegion(): void
100+
{
101+
$client = new StsClient([
102+
'region' => 'test',
103+
], new NullProvider());
104+
105+
$this->expectException(UnsupportedRegion::class);
106+
$client->presign(new AssumeRoleRequest(['RoleArn' => 'demo', 'RoleSessionName' => 'demo']));
107+
}
108+
89109
private function getClient(): StsClient
90110
{
91111
self::markTestSkipped('No Docker image for STS');

0 commit comments

Comments
 (0)