cloudyr / aws.s3

Amazon Simple Storage Service (S3) API Client
https://cloud.r-project.org/package=aws.s3
381 stars 148 forks source link

Modified endpoint/host when working with IBM Cloud Object Storage #369

Closed eli-mayost closed 4 years ago

eli-mayost commented 4 years ago

Working with IBM Cloud Object Storage with a regional bucket ("us-south").

The endpoint is s3.us-south.cloud-object-storage.appdomain.cloud

The host keeps getting modified (us.south get added first) and therefore not reachable as in the following reprex.

setwd("~/apps/r_apps/cmt/")

conf <- config::get("ibm_cos", file = "conf/config.yml")

Sys.setenv("AWS_ACCESS_KEY_ID"     = conf$access_key_id,
           "AWS_SECRET_ACCESS_KEY" = conf$secret_access_key,
           "AWS_S3_ENDPOINT"       = conf$endpoint)

aws.s3::bucket_list_df()
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL: no alternative certificate subject name matches target host 
name 'us.south.s3.us-south.cloud-object-storage.appdomain.cloud'

traceback()
#> No traceback available

sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-redhat-linux-gnu (64-bit)
#> Running under: Fedora 31 (Workstation Edition)
#> 
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.3          digest_0.6.25       aws.signature_0.6.0
#>  [4] R6_2.4.1            magrittr_1.5        evaluate_0.14      
#>  [7] httr_1.4.1          highr_0.8           rlang_0.4.6        
#> [10] stringi_1.4.3       curl_4.3            xml2_1.2.2         
#> [13] rmarkdown_2.0       config_0.3          tools_3.6.1         
#> [16] stringr_1.4.0       aws.s3_0.3.21       xfun_0.11          
#> [19] yaml_2.2.1          compiler_3.6.1      base64enc_0.1-3    
#> [22] htmltools_0.4.0     knitr_1.26

If I set region to an empty string then it works as expected:

setwd("~/apps/r_apps/cmt/")

conf <- config::get("ibm_cos", file = "conf/config.yml")

Sys.setenv("AWS_ACCESS_KEY_ID"     = conf$access_key_id,
           "AWS_SECRET_ACCESS_KEY" = conf$secret_access_key,
           "AWS_S3_ENDPOINT"       = conf$endpoint)

aws.s3::bucket_list_df(region = "")
#>                 Bucket             CreationDate
#> 1  sda-application-cmt 2020-07-16T15:03:22.525Z
#> 2 sda-application-data 2020-05-18T17:18:37.283Z

traceback()
#> No traceback available

sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-redhat-linux-gnu (64-bit)
#> Running under: Fedora 31 (Workstation Edition)
#>
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
#>
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C      
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C  
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base
#>
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.3          digest_0.6.25       aws.signature_0.6.0
#>  [4] R6_2.4.1            magrittr_1.5        evaluate_0.14
#>  [7] httr_1.4.1          highr_0.8           rlang_0.4.6
#> [10] stringi_1.4.3       curl_4.3            xml2_1.2.2
#> [13] rmarkdown_2.0       config_0.3          tools_3.6.1
#> [16] stringr_1.4.0       aws.s3_0.3.21       xfun_0.11  
#> [19] yaml_2.2.1          compiler_3.6.1      base64enc_0.1-3
#> [22] htmltools_0.4.0     knitr_1.26

Setting "AWS_DEFAULT_REGION" to "us-south" in Sys.setenv does not work either.

Is it a bug, or an issue in how IBM define its endpoint?

s-u commented 4 years ago

Use region="" in the call since it appears your endpoint doesn't use regions (see notes on non-AWS endpoints).