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

How to assume role #934

Closed
GeorgeHosuAdswizz opened this issue Nov 10, 2016 · 3 comments
Closed

How to assume role #934

GeorgeHosuAdswizz opened this issue Nov 10, 2016 · 3 comments
Labels
guidance Question that needs advice or information.

Comments

@GeorgeHosuAdswizz
Copy link

Hello, I have previously configured the aws cli in order to assume a role when I run commands on s3. However the cli does ask me to run each command as aws s3 --profile <my_role>.

When i try to use the go sdk however I simply get an access denied error. Is there any way to quickly configure the go aws sdk in order to assume a role before making any further requests to s3 ? It need to me secure (do note that I already have the require credentials inside ~/.aws/config)

@jasdel
Copy link
Contributor

jasdel commented Nov 10, 2016

@GeorgeHosuAdswizz thanks for contacting us. The simplest way to support what you're looking for it to set the env var AWS_SDK_LOAD_CONFIG=1, and then run your code using the SDK. This flag also enables support for assuming roles from the shared config file. This configuration will instruct the SDK to use the shared config file (~/.aws/config). By default without that flag set the SDK will not use the shared config.

The Sessions getting started guide has more information on this.

You can also do this in code too like the following:

    sess, err := session.NewSessionWithOptions(session.Options{
        // enable shared config support.
        SharedConfigState: SharedConfigEnable,

        // Optionally set the profile to use from the shared config.
        Profile: myProfile, 
    })

@jasdel jasdel added the guidance Question that needs advice or information. label Nov 10, 2016
@jasdel jasdel added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 14, 2016
@jasdel
Copy link
Contributor

jasdel commented Dec 14, 2016

Hi @GeorgeHosuAdswizz Thanks for reaching out to us, let us know if there is anything more we can answer or help with.

@jasdel jasdel closed this as completed Dec 14, 2016
@GeorgeHosuAdswizz
Copy link
Author

Tank you very much for the help, I was very busy at the time and forgot to close the issue, sorry for that :s
-Cheers

@diehlaws diehlaws removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants