Reputation: 157
I do not want to hardcode region id and pass region name as String from command line. Is there a way to do that? Hardcoding:
Region s3Region = Region.getRegion(Regions.US_EAST_1);
Non Hardcoded but not working:
Region s3Region = Region.getRegion(Regions.fromName(awsRegion));
Upvotes: 11
Views: 8885
Reputation: 115
Regions.valueOf(awsRegion)
should help.
Full code:
Region s3Region = Region.getRegion(Regions.valueOf(awsRegion.toUpperCase()));
Upvotes: 1
Reputation: 907
For software.amazon.awssdk use the below code.
import software.amazon.awssdk.regions.Region;
Region region= Region.of("Your-Region");
Note: Not for com.amazonaws:aws-java-sdk
Upvotes: 2
Reputation: 996
Answering the question that I think you mean to ask:
If you have an Amazon region name like, for example, "us-east-1" then you can easily convert it to a RegionEndpoint:
RegionEndpoint endpoint = Amazon.RegionEndpoint.GetBySystemName("us-east-1");
Upvotes: 15