Add support for a singleton Region in AwsIamAuthenticationOptions.
See gh-758
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user