I am working on aws. I am getting "Cannot create enum from " + regionName + " value!". I know we could change to the latest SDK jar file, but I want with out changing the jar file to rectify this issue. I am facing this issue at Regions.fromName(String regionName)
method. Here is my code:
for(com.amazonaws.services.ec2.model.Region region : describeRegionsResult.getRegions()){
String regionName = region.getRegionName();
Regions regionsValue = fromNames(regionName);
Region regionToDiscover = Region.getRegion(regionsValue);
}
Is there is way to convert describeRegionsResult.getRegions()
to com.amazonaws.regions.Regions
.
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.US_EAST_1 us-east-1
Regions.US_WEST_1 us-west-1
Regions.US_WEST_2 us-west-2
Regions.EU_WEST_1 eu-west-1
Regions.EU_CENTRAL_1 eu-central-1
Regions.AP_SOUTH_1 ap-south-1
Regions.AP_SOUTHEAST_1 ap-southeast-1
Regions.AP_SOUTHEAST_2 ap-southeast-2
Regions.AP_NORTHEAST_1 ap-northeast-1
Regions.AP_NORTHEAST_2 ap-northeast-2
Regions.SA_EAST_1 sa-east-1
Regions.CN_NORTH_1 cn-north-1
You can see when each region was added into the SDK here: https://github.com/aws/aws-sdk-java/blame/master/aws-java-sdk-core/src/main/java/com/amazonaws/regions/Regions.java
If you are trying to use one of those names with Regions.fromName
, but your version of the SDK doesn't have that yet, it is impossible to get an enum for that region. You must upgrade the SDK or keep the region as a String.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With