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

Sessions: Use STS regional endpoint in assume role for opt-in regions #129

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

idastambuk
Copy link
Contributor

@idastambuk idastambuk commented Feb 23, 2024

A bug was reported in cloudwatch when requesting resources and querying data for opt-in regions when the account is assuming a role. An error is returned from these endpoints InvalidClientTokenId: The security token included in the request is invalid

Opt-in regions are regions in AWS that have to be manually enabled in an AWS account.

When requesting tokens with Amazon STS like we do when assuming role, we have to pass the STSRegionalEndpoint field with value 'regional' so that the returned tokens can be used in opt in regions. Otherwise global endpoint is used, which returns tokens that don't work with opt-in regions (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html)

Screenshot 2024-02-22 at 18 19 25

As of aws-sdk-go-v2, STS service uses regional endpoints by default so this shouldn't be high impact. There's also the best practices outlined in the docs above for v1 that suggest to use regional sts endpoints.

So far, we've suggested users set the AWS_STS_REGIONAL_ENDPOINTS=regional option in their env vars, which aws/aws-sdk would read. However, this isn't possible for hosted Grafana instances.

Fixes https://github.com/grafana/support-escalations/issues/9155

To test this, you can use the assume role same account datasource from plugin provisioning, and query region eu-south-1 (opt in region that was manually enabled in the account). You should be getting "invalid token" before the fix, and query and resource requests with empty data after it and no errors

@idastambuk idastambuk requested a review from a team as a code owner February 23, 2024 11:03
Copy link
Contributor

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

This makes sense to me, but what region/credentials were you using to test this? (I want to try it out)

@idastambuk
Copy link
Contributor Author

idastambuk commented Feb 26, 2024

This makes sense to me, but what region/credentials were you using to test this? (I want to try it out)

Sorry about that, added testing instructions at the end!

@iwysiu
Copy link
Contributor

iwysiu commented Feb 26, 2024

Cool! I tried it and it worked

@idastambuk idastambuk merged commit c5299e1 into main Feb 26, 2024
3 checks passed
@idastambuk idastambuk deleted the sts branch February 26, 2024 16:46
@idastambuk idastambuk mentioned this pull request Feb 26, 2024
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.

None yet

3 participants