Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for assuming roles from web identities. #63

Merged
merged 47 commits into from
Feb 22, 2022

Conversation

markdouthwaite
Copy link
Contributor

Please ensure the following before submitting a PR:

  • if suggesting code changes or improvements, open an issue first
  • for all but trivial changes (e.g., typo fixes), add your name to DESCRIPTION
  • for all but trivial changes (e.g., typo fixes), documentation your change in NEWS.md with a parenthetical reference to the issue number being addressed
  • if changing documentation, edit files in /R not /man and run devtools::document() to update documentation
  • add code or new test files to /tests for any new functionality or bug fix
  • make sure R CMD check runs without error before submitting the PR

This PR adds support for assuming roles from web identities as requested in #62

Copy link
Contributor

@jon-mago jon-mago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there

Thanks for taking the time to write this Mark, and for your patience while I got back to you!

I have some comments on the changes which I've put on the relevant lines, though I'm happy to talk about any and all of them.

One other comment on this, and I appreciate this is probably a limitation of how the package is currently written, but I think this code is going to result in the package creating new temporary credentials for each request to AWS. This doesn't seem 100% ideal. But I don't have an easy fix for that.

DESCRIPTION Outdated
)
Description: Generates version 2 and version 4 request signatures for Amazon Web Services ('AWS') <https://aws.amazon.com/> Application Programming Interfaces ('APIs') and provides a mechanism for retrieving credentials from environment variables, 'AWS' credentials files, and 'EC2' instance metadata. For use on 'EC2' instances, users will need to install the suggested package 'aws.ec2metadata' <https://cran.r-project.org/package=aws.ec2metadata>.
License: GPL (>= 2)
Imports:
digest,
base64enc
base64enc,
httr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super keen on adding a big set of dependencies like httr to a package that previously had almost none. Can this be revised to use the curl and jsonlite packages as a slightly smaller set?

Copy link
Contributor

@lukedyer-peak lukedyer-peak Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this to just use curl and jsonlite

R/assume_role.R Outdated
content <- httr::content(response)

if (httr::status_code(response) == 200) {
message("Successfully fetched token.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably have the verbosity flagging as similar code does through the package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 addressed this in 1eac62d

@@ -12,7 +12,7 @@
#' @details These functions locate values of AWS credentials (access key, secret access key, session token, and region) from likely sources. The order in which these are searched is as follows:
#' \enumerate{
#' \item user-supplied values passed to the function
#' \item environment variables (\env{AWS_ACCESS_KEY_ID}, \env{AWS_SECRET_ACCESS_KEY}, \env{AWS_DEFAULT_REGION}, and \env{AWS_SESSION_TOKEN})
#' \item environment variables, first checking for Web Identity credentials (\env{AWS_ROLE_ARN} and \env{AWS_WEB_IDENTITY_TOKEN_FILE}), then default credentials (\env{AWS_ACCESS_KEY_ID}, \env{AWS_SECRET_ACCESS_KEY}, \env{AWS_DEFAULT_REGION}, and \env{AWS_SESSION_TOKEN})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a divergence from how boto3 grabs credentials, which favours env variables over provider type credentials like these. I would prefer the package remains consistent with the boto3 ordering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to favouring the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN over AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE.

@lukedyer-peak
Copy link
Contributor

@jon-mago - we've addressed all the review comments now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants