-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
provider/aws: Added sts:GetCallerIdentity to GetAccountId for federated logins #6385
provider/aws: Added sts:GetCallerIdentity to GetAccountId for federated logins #6385
Conversation
Thanks for discovering We could possibly use this to replace
That method is there to get around differences in environments where Terraform can run:
I'm happy to bump the In addition to all of the above resources should not be calling We should call that function once and save the account ID somewhere (possibly to |
21818f4
to
5e122e5
Compare
@radeksimko let me know what you think. I added accountid to the AWSClient. It looks good so far, I ran this against an existing deployment and it added tags to my aws_db_subnet_group. |
func getMockedAwsIamApi(endpoints []*iamEndpoint) (func(), *iam.IAM) { | ||
// getMockedAwsIamStsApi establishes a httptest server to simulate behaviour | ||
// of a real AWS' IAM & STS server | ||
func getMockedAwsIamStsApi(endpoints []*iamEndpoint) (func(), *iam.IAM, *sts.STS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind also adding the actual STS mock responses (for success + error) and two tests testing STS?
iam:GetUser
- 403 (failure)=>
sts:GetCallerIdentity
- 200 (success)iam:GetUser
- 403 (failure)=>
sts:GetCallerIdentity
- any failure=>
iam:ListRoles
- 200 (successful fallback to ListRoles)
You can use examples of responses from the API reference as mocks: http://docs.aws.amazon.com/STS/latest/APIReference/API_GetCallerIdentity.html
I left you some comments there, but overall this looks pretty good, I think it's quite close to to be merged. 👍 😉 Would you mind separating this into two PRs - one for adding the |
ad6a917
to
7f9db15
Compare
@radeksimko this one is updated to be the PR for sts:GetCallerIdentity only |
The second commit 7f9db15 LGTM, but I've got two reservations about the first one with dependencies:
|
d31ac4a
to
8dadb51
Compare
@radeksimko hows this? |
@bigkraig just one last thing - can you update your - "GodepVersion": "v63",
+ "GodepVersion": "v62", Try |
…ary includes GetCallerIdentity which can be used to build ARNs for RDS resources when using IAM roles
…hase. We use iam.GetUser(nil) scattered around to get the account id, but this isn't the most reliable method. GetAccountId now uses one more method (sts:GetCallerIdentity) to get the account id, this works with federated users.
8dadb51
to
a23bcf2
Compare
@radeksimko done! |
aws: Update docs after #6385 (account ID via sts)
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
The STS GetCallerIdentity function works for fetching the account id no matter how you're authenticated.
There appears to be a complicated GetAccountId function in auth_helpers.go that accomplishes the same thing. Since I don't know why that was created I didn't update that use, but I think that may be able to use the same method.