Add support for a singleton Region in AwsIamAuthenticationOptions.

See gh-758
This commit is contained in:
Mark Paluch
2023-03-17 10:22:08 +01:00
parent 4493901c93
commit 658ec5839c
2 changed files with 15 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ import java.net.URI;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.regions.providers.AwsRegionProvider;
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain;
@@ -212,6 +213,19 @@ public class AwsIamAuthenticationOptions {
return this;
}
/**
* Configure a {@link Region}, used for computing the signature.
* @param region must not be {@literal null}.
* @return {@code this} {@link AwsIamAuthenticationOptionsBuilder}.
* @since 3.0.2
*/
public AwsIamAuthenticationOptionsBuilder region(Region region) {
Assert.notNull(region, "Region must not be null");
return regionProvider(() -> region);
}
/**
* Configure an {@link AwsRegionProvider}, required to calculate the region to be
* used for computing the signature.

View File

@@ -89,7 +89,7 @@ class AwsIamAuthenticationUnitTests {
+ "}"));
AwsIamAuthenticationOptions options = AwsIamAuthenticationOptions.builder().role("foo-role")
.regionProvider(() -> Region.US_WEST_1).credentials(AwsBasicCredentials.create("foo", "bar")).build();
.region(Region.US_WEST_1).credentials(AwsBasicCredentials.create("foo", "bar")).build();
AuthenticationSteps steps = AwsIamAuthentication.createAuthenticationSteps(options);
AuthenticationStepsExecutor executor = new AuthenticationStepsExecutor(steps, this.restTemplate);