paws-r / paws

Paws, a package for Amazon Web Services in R
https://www.paws-r-sdk.com
Other
315 stars 37 forks source link

status of iam_credentials_provider #750

Closed tyner closed 7 months ago

tyner commented 7 months ago

On our EMR cluster, we are using IMDSv2, and as a result, aws.signature::locate_credentials() is not able to find the credentials, even when the aws.ec2metadata package is available. On the other hand, the non-exported function paws.common:::iam_credentials_provider() still works just fine. Since it is a non-exported function, we are wondering if there is an exported wrapper we should be using instead, perhaps from a different package? If not, would it make sense to start exporting iam_credentials_provider so that it is part of the official API? Regards, Ben

DyfanJones commented 7 months ago

I am not opposed to exporting iam_credentials_provider.

DyfanJones commented 7 months ago

🤔 should all providers be exported or maybe something similar to aws.signature locate_credentials

DyfanJones commented 7 months ago

Hi @tyner I believe I have an initial method. Currently named the same as aws.signature (not tied to the name so any better suggestions are welcome). Please have a go and let me know

remotes::install_github("dyfanjones/paws/paws.common", ref = "locate_credentials")

paws.common::locate_credentials()
tyner commented 7 months ago

Hi @tyner I believe I have an initial method. Currently named the same as aws.signature (not tied to the name so any better suggestions are welcome). Please have a go and let me know

remotes::install_github("dyfanjones/paws/paws.common", ref = "locate_credentials")

paws.common::locate_credentials()

Thanks, is there a .tar.gz I can use to test? (access to github is blocked from our environment)

DyfanJones commented 7 months ago

If you have access to r-universe https://paws-r.r-universe.dev/paws.common you could use:

install.packages('paws.common', repos = c('https://paws-r.r-universe.dev', 'https://cloud.r-project.org'))

Alternatively can you get the .tar.gz from this link :) https://paws-r.r-universe.dev/bin/linux/jammy/4.3/src/contrib/paws.common_0.7.0.9000.tar.gz

tyner commented 7 months ago

That paws.common_0.7.0.9000.tar.gz looks like a binary package? We are required to use a source package.

DyfanJones commented 7 months ago

You could try out the function directly is you wish:

locate_credentials <- function(profile = "", anonymous = FALSE) {
  credentials <- paws.common:::Credentials(profile = profile, anonymous = anonymous)
  result <- as.list(paws.common:::get_credentials(credentials)$creds)
  result$region <- paws.common:::get_region(profile)
  return(result[names(result) != "provider_name"])
}
tyner commented 7 months ago

Works like a charm, thank you @DyfanJones !

DyfanJones commented 7 months ago

Closing as paws.common 0.7.1 is now on the cran