Skip to content

Commit

Permalink
set default region to us-east-1 for aws s3 services
Browse files Browse the repository at this point in the history
  • Loading branch information
DyfanJones authored Jan 3, 2024
2 parents e90c2fd + 6b3dd03 commit 2d0b3fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions paws.common/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* add pagination StopOnSameToken option (#721) aligns with aws-sdk-js-v3 implementation (https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.78.0). Thanks to @wlandau for raising error in `paginate`.
* tidy up internal function `jmespath_index`
* fix `aws-global` region when resolving endpoint (#730). Thanks to @atheriel for identifying the issue.
* fix default region for service s3 (#730). Thanks to @atheriel for identifying the issue.

# paws.common 0.6.4
* ensure xml build structure is correctly flattened (#597)
Expand Down
5 changes: 5 additions & 0 deletions paws.common/R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ resolver_endpoint <- function(service, region, endpoints, sts_regional_endpoint
match <- matches[order(nchar(matches), decreasing = TRUE)][1]
return(match)
}
# Set default region for s3:
# https://github.com/boto/botocore/blob/develop/botocore/regions.py#L189-L220
if (service == "s3" & (region == "aws-global")) {
region <- "us-east-1"
}
# locate global endpoint
global_found <- vapply(
endpoints, function(x) if (is.list(x)) x$global else FALSE,
Expand Down
11 changes: 11 additions & 0 deletions paws.common/tests/testthat/test_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ test_that("resolver_endpoint service sts_regional_endpoint", {
expect_equal(r$signing_region, "us-east-1")
})

test_that("resolver_endpoint service s3 default region", {
endpoints <- list(
"*" = list(endpoint = "https://{service}.amazonaws.com", global = FALSE),
"us-west-*" = list(endpoint = "https://us-west.amazonaws.com", global = TRUE)
)

r <- resolver_endpoint("s3", "aws-global", endpoints)
expect_equal(r$endpoint, "https://s3.amazonaws.com")
expect_equal(r$signing_region, "us-east-1")
})

test_that("client_config uses custom endpoint", {
Sys.setenv("AWS_REGION" = "region")
cfgs <- Config()
Expand Down

0 comments on commit 2d0b3fd

Please sign in to comment.