ministryofjustice / analytics-platform

Parent repository for the MOJ Analytics Platform
MIT License
14 stars 1 forks source link

region not set in s3tools #85

Closed davidread closed 5 years ago

davidread commented 5 years ago

What happened?

AH has had issues uploading to S3 via s3tools::write_file_to_s3() - getting "Moved permanently" error. I thought this was fixed in the latest s3tools? How does one change the region?

Workaround:

Sys.setenv("AWS_DEFAULT_REGION" = "eu-west-1")

Steps to reproduce the problem

TODO

ben-lavelle commented 5 years ago

It's worth noting, following our experience of sys envs for PAT storage, that Sys.setenv() if run only in the current session, will only set the environment variable for that session and that project--a change of either wipes it.

A stronger fix, instead, is to include this envset in a user .Rprofile that initialises for all sessions for all projects. The call (which only needs to be done once for a user) is

writeLines('Sys.setenv("AWS_DEFAULT_REGION" = "eu-west-1")', con = "~/.Rprofile")
davidread commented 5 years ago

Yeah, I expect the problem was something like this.

Since the day after this issue was opened, the env variable was changed to be set in /usr/local/lib/R/etc/Renviron rather than /etc/R/Renviron: https://github.com/ministryofjustice/analytics-platform-rstudio/commit/cadc931a428ea56eae9445262b79d0b040f8829a which may have helped - I'll assume this fixed the issue as we've not got any records of it occurring again. I think would set the env var whenever R Studio starts. Happy to look at this again if anyone gets it again.