Skip to content

Commit 014e831

Browse files
committed
Add support for a singleton Region in AwsIamAuthenticationOptions.
See gh-758
1 parent a11769d commit 014e831

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

spring-vault-core/src/main/java/org/springframework/vault/authentication/AwsIamAuthenticationOptions.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import software.amazon.awssdk.auth.credentials.AwsCredentials;
2121
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
2222
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
23+
import software.amazon.awssdk.regions.Region;
2324
import software.amazon.awssdk.regions.providers.AwsRegionProvider;
2425
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain;
2526

@@ -212,6 +213,19 @@ public AwsIamAuthenticationOptionsBuilder credentialsProvider(AwsCredentialsProv
212213
return this;
213214
}
214215

216+
/**
217+
* Configure a {@link Region}, used for computing the signature.
218+
* @param region must not be {@literal null}.
219+
* @return {@code this} {@link AwsIamAuthenticationOptionsBuilder}.
220+
* @since 3.0.2
221+
*/
222+
public AwsIamAuthenticationOptionsBuilder region(Region region) {
223+
224+
Assert.notNull(region, "Region must not be null");
225+
226+
return regionProvider(() -> region);
227+
}
228+
215229
/**
216230
* Configure an {@link AwsRegionProvider}, required to calculate the region to be
217231
* used for computing the signature.

spring-vault-core/src/test/java/org/springframework/vault/authentication/AwsIamAuthenticationUnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void shouldUsingAuthenticationSteps() {
8989
+ "}"));
9090

9191
AwsIamAuthenticationOptions options = AwsIamAuthenticationOptions.builder().role("foo-role")
92-
.regionProvider(() -> Region.US_WEST_1).credentials(AwsBasicCredentials.create("foo", "bar")).build();
92+
.region(Region.US_WEST_1).credentials(AwsBasicCredentials.create("foo", "bar")).build();
9393

9494
AuthenticationSteps steps = AwsIamAuthentication.createAuthenticationSteps(options);
9595
AuthenticationStepsExecutor executor = new AuthenticationStepsExecutor(steps, this.restTemplate);

0 commit comments

Comments
 (0)