TL;DR: What's THE BEST method of ensuring all resources have a set of tags?
I have a set of three tags, Component, Stack and Project, that I want present in any resource that can have tags.
I'm using Pulumi as my IaaS tool. I'm already using a Pulumi policy to ensure that resources have the required tags when I create them via Pulumi.
Since I'm using AWS Organizations, I can use a Tag Policy to ensure some resources have the required tags. However, this policy does not encompass all existing resources that can have tags.
I could use a SCP, but that seems cumbersome to maintain and difficult to reason about properly.
I tried something like:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceComponentTag",
"Effect": "Deny",
"Action": [
"*"
],
"Resource": [
"*"
],
"Condition": {
"Null": {
"aws:RequestTag/Component": "true"
}
}
}
]
}
But of course this is not working because it blocks get/describe requests, for example.
One could also try something like:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceComponentTag",
"Effect": "Deny",
"Action": [
"aps:Create*",
"aps:Delete*",
"aps:Put*"
],
"Resource": [
"*"
],
"Condition": {
"Null": {
"aws:RequestTag/Component": "true"
}
}
}
]
}
But I feel this is cumbersome to write and maintain and may lead to hard to debug bugs, as well as missing some resources.
Finally, there is also the AWS Config service to keep track of untagged resources.
What other alternatives exist to ensure all resources have a certain set of tags?
As of now AWS does not have any straight forward simple solution of implementing mandatory tags. You need to work around and implement the best solution that is efficient for you.
While you've already examined approaches such as Pulumi policies, AWS Organizations Tag Policies, and SCPs, there are additional strategies you can look into -
1. AWS Resource Groups
2. Tag Editor
3. Automation Script -
4. Resource create alert
Fyr, You can refer to the SCP policy that is currently implemented in my account