Fix incorrect AWS region when specifying a S3 regional endpoint #6530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
close #6528
This PR fixes a bug introduced when porting to AWS SDK v2. Nexflow sets the global region (US-EAST-1) when an amazon endpoint is defined, without checking if it is a regional endpoint. In AWS SDK v1, the s3 client didn't include a region when a endpoint was specified. However, the AWS SDK v2 S3 client require to define a region. It was resolved using the AwsS3Config.getS3GlobalRegion() that overwrites the region specified by the user if an amazon endpoint was specified, incorrectly assuming that endpoint refers to a global endpoint.
This PR changes how the region is resolved when a endpoint is defined. First, it tries to get the region from the endpoint. If region in the endpoint, it tries to get from config or environment vars. Finally, fallback to us-east-1 if other options fail.