nfultz / AWR.Athena

Short R Wrapper for Athena JDBC connections
23 stars 13 forks source link

Notes from a newbie regarding credentials configuration #24

Open maelle opened 4 years ago

maelle commented 4 years ago

Heya here, thanks for the package.

I'm just writing down notes regarding configuration in case it can be added somewhere in the docs / can help another newbie (I read issues to understand that environment variables didn't mean R environment variables :slightly_smiling_face: )

First note for newbies: to get the key and key ID go into your "My security credentials" settings from the drop-down menu at the top right of the console where your username is.

I was hoping to be able to use keyring and Sys.setenv() but since environment variables are not read by R and I seem to be too unaware of Java/Ubuntu I ended up installing AWS CLI and running aws configure which was fairly straightforward and now I can open a connection. :-)

I suppose that because R doesn't handle the credentials there's no way to check the configuration worked from R without trying to establish a connection?

daroczig commented 4 years ago

What do you mean by "environment variables are not read by R"? It should work.

But to set persistent config, you just need to create ~/.aws/credentials as per https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where (that is done by aws configure, but you can manually create as well)

maelle commented 4 years ago

I mean I can't use something like Sys.setenv(varname=keyring::get_value(varnane)) (nor .Renviron)

Zirkonium88 commented 4 years ago

I don't understand this issue. Here you find a description:

https://docs.rstudio.com/rspm/admin/s3-config.html

With Sys.setenv('AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE')and so on you can specify credentials with your RStudio environment.

Within AWS EC2 you can use the cloudyr package to retrieve credentials from 'http://169.254.169.254...'.

Within Fargate (Shiny) you need to call:


# Write values to .Renviron
env | grep AWS_ >> /home/shiny/.Renviron
chown shiny.shiny /home/shiny/.Renviron

So several ops ...

maelle commented 4 years ago

Ah then I must have made another mistake, feel free to close, sorry.

maelle commented 4 years ago

Issue comment I misunderstood https://github.com/nfultz/AWR.Athena/issues/20#issuecomment-516586181

nfultz commented 4 years ago

Environment variables are used, but when the rJava process is started (one of the librarys AWR.Athena uses), it keeps it's own copy of the environment, so changing R's copy will not have an effect.