The SDK v2 does not provide a Regions enum like v1 used to (was: Missing us-east-1 in BucketLocationConstraint)
See original GitHub issueDescribe the bug
We are using BucketLocationConstraint to bind application properties to a valid S3 Region.
Related : https://github.com/aws/aws-sdk-java-v2/issues/1324
Expected Behavior
The object s3Region is instantiated.
Current Behavior
java.lang.IllegalArgumentException: No enum constant software.amazon.awssdk.services.s3.model.BucketLocationConstraint.us-east-1
Reproduction Steps
demo.s3.region: "us-east-1"
@ConfigurationProperties("demo")
public class S3Properties {
BucketLocationConstraint s3Region;
}
Possible Solution
Add the missing value(s) to service-2.json
Additional Information/Context
Note: this value is then passed to the S3Client builder like so :
S3Client.builder()
.region(Region.of(s3Properties.getRegion().toString()))
We looked into using a Region enum directly, but we could not find an equivalent of the Regions enum from AWS SDK v1.
AWS Java SDK version used
2.17.246
JDK version used
17.0.4
Operating System and version
macOS Monterey 12.5
Issue Analytics
- State:
- Created a year ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Regions (AWS SDK for Java - 1.12.363)
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate...
Read more >types - Go Packages
In terms of implementation, a Bucket is a resource. An Amazon S3 bucket name is globally unique, and the namespace is shared by...
Read more >aws "Cannot create enum from " + regionName + " value!"
The latest version of the Java SDK as of this answer (1.11.13) supports the following Regions: Enum Name Regions.GovCloud us-gov-west-1 Regions.
Read more >BucketLocationConstraint (AWS SDK for Java - 2.18.17)
declaration: package: software.amazon.awssdk.services.s3.model, enum: BucketLocationConstraint.
Read more >https://raw.githubusercontent.com/aws/aws-sdk-go/m...
Amazon S3 transfer acceleration does not support cross-Region copies. ... signature calculations // in Signature Version 4 must use us-east-1 as the Region, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@maciejwalkowiak Thank you for your help.
This is not a Spring Boot issue. In fact, it is able to bind Strings to
Region
s without a converter.The issue is that
Region
allows building objects with invalid region identifiers, such as “first”.Using the AWS SDK for Java v1, one can use the enum
Regions
and get type safety.Using the AWS SDK for Java v2, I ended up building my own wrapper :
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.