Skip to content

Commit

Permalink
attempting to access more regions than are in the Regions enum
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryGeorgist committed Apr 23, 2024
1 parent 6efea2e commit edee66a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main/java/usace/cc/plugin/CcStoreS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.regions.Regions;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.RegionUtils;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.AmazonS3Exception;
Expand Down Expand Up @@ -54,7 +56,7 @@ public CcStoreS3(){
//System.out.println(EnvironmentVariables.CC_PROFILE + "_" + EnvironmentVariables.AWS_ACCESS_KEY_ID+"::"+config.aws_access_key_id);
//System.out.println(EnvironmentVariables.CC_PROFILE + "_" + EnvironmentVariables.AWS_SECRET_ACCESS_KEY+"::"+config.aws_secret_access_key_id);
//System.out.println(EnvironmentVariables.CC_PROFILE + "_" + EnvironmentVariables.AWS_S3_BUCKET+"::"+config.aws_bucket);
Regions clientRegion = Regions.valueOf(config.aws_region.toUpperCase().replace("-", "_"));
Region clientRegion = RegionUtils.getRegion(config.aws_region.toUpperCase().replace("-", "_"));//Regions.valueOf(config.aws_region.toUpperCase().replace("-", "_"));
try {
AmazonS3 s3Client = null;
if(config.aws_mock){
Expand All @@ -70,7 +72,7 @@ public CcStoreS3(){

s3Client = AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.aws_endpoint, clientRegion.name()))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.aws_endpoint, clientRegion.getName()))
.withPathStyleAccessEnabled(config.aws_force_path_style)
.withClientConfiguration(clientConfiguration)
.withCredentials(new AWSStaticCredentialsProvider(credentials))
Expand All @@ -79,7 +81,7 @@ public CcStoreS3(){
AWSCredentials credentials = new BasicAWSCredentials(config.aws_access_key_id, config.aws_secret_access_key_id);
s3Client = AmazonS3ClientBuilder
.standard()
.withRegion(clientRegion)
.withRegion(clientRegion.getName())
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/usace/cc/plugin/FileDataStoreS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.regions.Regions;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.RegionUtils;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.DeleteObjectRequest;
Expand Down Expand Up @@ -101,7 +103,7 @@ public FileDataStoreS3(DataStore ds){
//System.out.println(ds.getDsProfile() + "_" + EnvironmentVariables.AWS_SECRET_ACCESS_KEY+"::"+config.aws_secret_access_key_id);
//System.out.println(ds.getDsProfile() + "_" + EnvironmentVariables.AWS_S3_BUCKET+"::"+config.aws_bucket);

Regions clientRegion = Regions.valueOf(config.aws_region.toUpperCase().replace("-", "_"));
Region clientRegion = RegionUtils.getRegion(config.aws_region.toUpperCase().replace("-", "_"));//Regions.valueOf(config.aws_region.toUpperCase().replace("-", "_"));
try {
AmazonS3 s3Client = null;
if(config.aws_mock){
Expand All @@ -112,7 +114,7 @@ public FileDataStoreS3(DataStore ds){

s3Client = AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.aws_endpoint, clientRegion.name()))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.aws_endpoint, clientRegion.getName()))
.withPathStyleAccessEnabled(config.aws_force_path_style)
.withClientConfiguration(clientConfiguration)
.withCredentials(new AWSStaticCredentialsProvider(credentials))
Expand All @@ -121,7 +123,7 @@ public FileDataStoreS3(DataStore ds){
AWSCredentials credentials = new BasicAWSCredentials(config.aws_access_key_id, config.aws_secret_access_key_id);
s3Client = AmazonS3ClientBuilder
.standard()
.withRegion(clientRegion)
.withRegion(clientRegion.getName())
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
}
Expand Down

0 comments on commit edee66a

Please sign in to comment.