Last active
May 16, 2023 15:42
-
-
Save flowerinthenight/33f5e03e9990abcc01203acbea178a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctx := context.Background() | |
assumecnf, _ := config.LoadDefaultConfig( | |
ctx, config.WithRegion("{aws-region}"), | |
config.WithCredentialsProvider(aws.NewCredentialsCache( | |
credentials.NewStaticCredentialsProvider( | |
"{aws-assume-role-key}", | |
"{aws-assume-role-secret}", "", | |
)), | |
), | |
) | |
stsclient := sts.NewFromConfig(assumecnf) | |
cnf, _ := config.LoadDefaultConfig( | |
ctx, config.WithRegion("{aws-region}"), | |
config.WithCredentialsProvider(aws.NewCredentialsCache( | |
stscredsv2.NewAssumeRoleProvider( | |
stsclient, | |
"{rolearn-to-assume}", | |
)), | |
), | |
) | |
client := s3.NewFromConfig(cnf) | |
res, _ := client.GetObject(ctx, &s3.GetObjectInput{ | |
Bucket: awsv2.String("{some-bucket}"), | |
Key: awsv2.String("{some-key}"), | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just want to say "thank you!!!" - this was a big help (and somehow not something readily available in the AWS documentation).