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

Credentials fail when aws.ec2metadata is not available #144

Closed
leeper opened this issue Jun 28, 2017 · 3 comments
Closed

Credentials fail when aws.ec2metadata is not available #144

leeper opened this issue Jun 28, 2017 · 3 comments
Labels

Comments

@leeper
Copy link
Member

leeper commented Jun 28, 2017

From 9627d8f

When running from 0.3.4 I get this error:

Loading required namespace: aws.ec2metadata
Failed with error:  'there is no package called 'aws.ec2metadata''
Error in locate_credentials(key = key, secret = secret, session_token = session_token,  :
  object 'cred' not found
Calls: source ... eval -> <Anonymous> -> s3HTTP -> locate_credentials
Execution halted

We reverted to the 0.3.3 version found on CRAN and that solved it.

If we install aws.ec2metadata the error becomes:

Loading required namespace: aws.ec2metadata
Error in curl_fetch_memory(uri) : Couldn't connect to server
Error in curl_fetch_memory(uri) :
  URL using bad/illegal format or missing URL
Error in role[["AWS_ACCESS_KEY_ID"]] : subscript out of bounds
Calls: source ... eval -> <Anonymous> -> s3HTTP -> locate_credentials
Execution halted
@danielerapati
Copy link

Thank you for opening this issue.

A key information is that we don't run from an EC2 and pass the credentials as environment variables.

@willbowditch
Copy link

Problem appears to be that role <- try(get_ec2_role(verbose = verbose), silent = TRUE) returns

[1] "AccessKeyId"     "Code"            "Expiration"      "LastUpdated"     "SecretAccessKey"
[6] "Token"           "Type" 

but locate_credentials() expects similar names but with underscores:

if (!inherits(role, "try-error")) {
      if (!is.null(role[["AWS_ACCESS_KEY_ID"]])) {
        key <- role[["AWS_ACCESS_KEY_ID"]]
        if (isTRUE(verbose)) {
          message("Using EC2 Instance Metadata for AWS Access Key ID")
        }
      }
      if (!is.null(role[["AWS_SECRET_ACCESS_KEY"]])) {
        secret <- role[["AWS_SECRET_ACCESS_KEY"]]
        if (isTRUE(verbose)) {
          message("Using EC2 Instance Metadata for AWS Secret Access Key")
        }
      }
      if (!is.null(role[["AWS_SESSION_TOKEN"]])) {
        session_token <- role[["AWS_SESSION_TOKEN"]]
        if (isTRUE(verbose)) {
          message("Using EC2 Instance Metadata for AWS Session Token")
        }
      }
      if (!is.null(role[["AWS_DEFAULT_REGION"]])) {
        region <- role[["AWS_DEFAULT_REGION"]]
        if (isTRUE(verbose)) {
          message(sprintf("Using EC2 Instance Metadata for AWS Region ('%s')", 
            region))
        }
      }

@leeper
Copy link
Member Author

leeper commented Jun 29, 2017

Folding this into #142

@leeper leeper closed this as completed Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants