Giter Club home page Giter Club logo

Comments (5)

emmansh avatar emmansh commented on September 28, 2024

OK I've made some progress! This comment is a great reference. But still unclear why the s3_staging_dir can't be read from the config file.

# .aws/config

[profile my-profile-master]
region = us-east-1
output = json

[profile my-profile-foo]
source_profile = my-profile-master
include_profile = my-profile-master
s3_staging_dir = s3://foo/bar/baz
schema_name = blah
duration_seconds = 3600
role_arn = arn:aws:iam::1234567890:role/Name-Of-Role
work_group = my-foo-bar-workgroup
# ❌ doesn't work
con <- DBI::dbConnect(noctua::athena(), 
                      region = "us-east-1",
                      profile_name = "my-profile-foo"
                      )

Error: Please set s3_staging_dir either in parameter s3_staging_dir, environmental varaible AWS_ATHENA_S3_STAGING_DIRor when work_group is defined in create_work_group()

However, this works:

# ✅ works
con <- DBI::dbConnect(noctua::athena(), 
                      region = "us-east-1",
                      profile_name = "my-profile-foo",
                      s3_staging_dir = "s3://foo/bar/baz"
                      )

Is there a way to make DBI::dbConnect() read the s3_staging_dir value from the config file?

from noctua.

DyfanJones avatar DyfanJones commented on September 28, 2024

Hi @emmansh,

Currently notua only gets AWS values from .aws/config and .aws/credentials (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html). This is done through paws sdk. However noctua does allow environment variables to be set as well. So for example all aws config setting can be store in .aws/config or .aws/credentials and noctua setting can be stored as environmental variables.

To do this you can use the R package usethis. This can set environment variables in the .Renviron file.

usethis::edit_r_environ()
AWS_ATHENA_S3_STAGING_DIR=s3://my-athena-bucket/query/location/

After reseting your session, AWS_ATHENA_S3_STAGING_DIR will be available. You can then set up a connection:

con <- dbConnect(noctua::athena(), profile = "my-profile-foo")

I hope this helps :)

Note: if you are using an Athena work group. noctua will attempt to retrieve the S3 staging dir from it. So you won't need to hard code it :)

from noctua.

DyfanJones avatar DyfanJones commented on September 28, 2024

Here are a list of supported environmental variables that aren't in .aws/config or .aws/credentials.

  • AWS_ATHENA_S3_STAGING_DIR: is equivalent to the dbConnect parameter - s3_staging_dir
  • AWS_ATHENA_WORK_GROUP: is equivalent to dbConnect parameter - work_group

from noctua.

DyfanJones avatar DyfanJones commented on September 28, 2024

I am happy for any PRs if you would like to add this feature to noctua :)

from noctua.

emmansh avatar emmansh commented on September 28, 2024

Sounds good, thank you!

from noctua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.