Enforce tagging across your environment and resources
- Establish controls to ensure new resources are tagged on creation.
- Use Infrastructure as Code to easily deploy and maintain tags in your environment.
- Establish mechanisms to remediate non-compliant resources with your tagging strategy and automate these mechanisms when possible.
Because of the importance of tagging and the level of complexity, we recommended that you automate the tagging process when possible. This reduces the human error that can be introduced when tagging critical resources, and minimizes the number of resources that are not identifiable due to the lack of tags. When possible, creating tag policies in your organization can help you ensure that the tags assigned to resources have the correct value assigned.
Additionally, automation needs to be established in the environment to discover resources with missing tags or resources that are not compliant with the established tagging strategy. Once the resources have been identified, a report including these resources on the environment needs to be sent to the relevant stakeholders, to evaluate and make a decision to remediate the situation, if needed.
Based on the results of this report, if a situation where persistent resources that are identified as non-compliant or have missing tags is given, it should be remediated immediately. This can be done by assigning a default pre-defined tag value defined as part of your tagging strategy. If a pre-defined tag doesn’t exist, delete the non-compliant resources.
As part of your tagging strategy, it is important to implement preventative controls that ensure that disallow resources from being created if they do not have the appropriate tags (review the Establishing preventive controls across your environment section in the Identity Management & Access Control Capability).
Establish controls to ensure new resources are tagged on creation
As you implement your tagging strategy, it is important to have a method to build, enforce, and maintain standardization within your environment. Tag policies are a type of policy that can help you standardize tag values based on defined tag keys across resources in your organization's accounts.
We consider the following tags mandatory, so we recommend using tag policies to help enforce the usage of the tag values according to our best practices. The following table is a sample that you can use to create your own tagging dictionary for the tags that are mandatory within your environment.
Tag Key |
Tag Purpose |
Sample Tag Values |
Observations |
Tag Key |
Tag Purpose |
Sample Tag Values |
Observations |
Owner |
Indicates the owner of the resource. |
SecurityLead, SecOps, Workload-1-Development-team |
This value should represent a team or a title, given that humans come and go, but the function remains within your environment. |
Business Unit |
Indicates the business unit for the resource. |
Finance, Retail, API-1, DevOps |
SDLC Stage |
Indicates the lifecycle stage for the resource. |
Sandbox, Dev, PreProd, QA, Prod, Testing |
Cost Center |
Indicates the cost center associated with the resource. |
FIN123,Retail-123,Sales-248,HR-333 |
Financial Owner |
Indicates the Financial Owner associated with the resource. |
HR, SecurityLead, DevOps-3, Workload-1-Development-team |
This value should represent a team or a title, given that humans come and go, but the function remains within your environment. |
Compliance Requirement |
Indicates if the resource is subject to any compliance requirement. |
N/A, NIST, HIPAA, GDPR, |
You can create tag policies to enforce the values you choose across your environment, and use the tag policies to prevent the creation of non-compliant resources. You can create these tag policies through the console, deploy them using IaC, in the AWS CLI, or one of the available SDKs. Using the sample dictionary defined previously, the following is a tag policy example that implements all the required tags:
{ "tags": { "Owner": { "tag_key": { "@@assign": "Owner" }, "tag_value": { "@@assign": [ "SecurityLead", "SecOps", "DevTeam1" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } }, "businessUnit": { "tag_key": { "@@assign": "BusinessUnit" }, "tag_value": { "@@assign": [ "Finance", "Retail" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } }, "costcenter": { "tag_key": { "@@assign": "CostCenter" }, "tag_value": { "@@assign": [ "100", "200" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } } ,"FinancialOwner": { "tag_key": { "@@assign": "FinancialOwner" }, "tag_value": { "@@assign": [ "SecOps", "HR" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } } ,"costcenter": { "tag_key": { "@@assign": "CostCenter" }, "tag_value": { "@@assign": [ "100", "200" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } } ,"compliance": { "tag_key": { "@@assign": "Compliance" }, "tag_value": { "@@assign": [ "NIST", "HIPAA", "GDPR" ] }, "enforced_for": { "@@assign": [ "<service>:*" ] } } }}
Note: Tag policies can be set to enforced or not enforced. Tag policies that are set to enforced prevent the instantiation of resources with non-compliant tag values. Tag policies that are not set to enforced allow the creation of the resource, but provide an organization level view of non-compliant resources. Refer to the evaluating organization-wide compliance section of the AWS Resource Groups user guide for more information on evaluating organization tag compliance.
After defining the tag policies in your environment you can use the Resource Group API to identify and correct non-compliant resources across your environment.
For resources that do not support tag policies, you can use preventive and detective controls to enforce tagging across your environment.
Preventive controls
Tagging policies enforce the use of defined tag values for defined tag keys. You can use Service Control Policies to prevent actions from being deployed in your environment when the expected tag keys are not included with the API calls. To achieve that, within your Service Control Policies to scope the permissions across your environment, you need to include a condition that will prevent the API call when the requested tag is not included in the resource. This is what it would look like to prevent an action when the CostCenter requested tag is not included within the call.
"Condition": { "Null": { "aws:RequestTag/costcenter": "true" } }
These preventive controls can also be used to provide Attribute Based Access Control when certain tags are present within a Role or a User making AWS API calls to the service. This is something we will explore further in a later section within the Identity Management & Access Control Capability.
Tagging limitations and additional tags
In addition to the tags you define in your environment, specific services use tags to monitor and track resources created or managed through them. These tags are reserved and start with a prefix that contains aws:. Tags starting with that prefix can’t be manually created, updated, or deleted.
For a list of the different tagging limitations on AWS, review tag naming limits and requirements.
Use infrastructure-as-code to deploy and maintain tags in your environment
We recommend enforcing tagging through Infrastructure as Code. This will automatically apply tags across your environment when creating resources as they are passed down directly from your templates, and pipelines. You can build preventive mechanisms to enforce the tags. Tools such as cfn-guard can help you check your IaC for compliance rules and enforce the required tags.