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

Work around the resourcegroupsapi being broken if called outside us-east-1 #29

Merged

Conversation

andrewjhumphrey
Copy link
Contributor

@andrewjhumphrey andrewjhumphrey commented Sep 6, 2022

We use the resourcegroupstaggingapi to efficiently fetch tagging information for policies, sadly it returns incorrect information when used outside of the us-east-1 for global resources like IAM policies. This is expected behaviour according to AWS support (this link only works in the customer-staging account).

You can test this for yourself by running something like this in an account you have access to:

% aws resourcegroupstaggingapi get-resources --resource-arn-list arn:aws:iam::<ACCOUNTNUMBER>:policy/SSO-Glue-Read-Only --region us-east-1
{
    "ResourceTagMappingList": [
        {
            "ResourceARN": "arn:aws:iam::090413119358:policy/SSO-Glue-Read-Only",
            "Tags": [
                {
                    "Key": "iamy-ignore",
                    "Value": "true"
                }
            ]
        }
    ]
}
% aws resourcegroupstaggingapi get-resources --resource-arn-list arn:aws:iam::<ACCOUNTNUMBER>:policy/SSO-Glue-Read-Only --region eu-west-1
{
    "ResourceTagMappingList": []
}

So this PR forces the use of us-east-1 for the resourcegroupstaggingapi, ignoring whatever config file or environment variable settings the user has.

simpson-ross
simpson-ross previously approved these changes Sep 6, 2022
Copy link

@simpson-ross simpson-ross left a comment

Choose a reason for hiding this comment

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

👍 to the change (and thanks!)

😢 to tabs-vs-spaces

stergiom
stergiom previously approved these changes Sep 6, 2022
petervandoros
petervandoros previously approved these changes Sep 6, 2022
Copy link

@petervandoros petervandoros left a comment

Choose a reason for hiding this comment

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

Tested and confirmed working 🎉

Thanks!

@andrewjhumphrey
Copy link
Contributor Author

😢 to tabs-vs-spaces
Fixed, but now you have to +1 again, sorry.

@andrewjhumphrey andrewjhumphrey merged commit 5fdf22c into main Sep 7, 2022
@andrewjhumphrey andrewjhumphrey deleted the andrewjhumphrey-force-us-east-1-for-resource-fetches branch September 7, 2022 01:58
@viraptor
Copy link
Contributor

viraptor commented Sep 8, 2022

Are bucket policies also considered global? Will they be found correctly after this change?

@andrewjhumphrey
Copy link
Contributor Author

Are bucket policies also considered global? Will they be found correctly after this change?

I wondered the same thing, but there is power in diversity 😄 bucket tags are fetched through a different mechanism:

https://github.com/envato/iamy/blob/main/iamy/s3.go#L165-L183

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.

6 participants