{"id":1088,"date":"2023-09-11T02:56:00","date_gmt":"2023-09-11T02:56:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=1088"},"modified":"2023-09-11T02:56:00","modified_gmt":"2023-09-11T02:56:00","slug":"aws-tag-policy","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=1088","title":{"rendered":"AWS Tag Policy Explained For Beginners"},"content":{"rendered":"<p>In this blog, we will learn about <strong>AWS tag policies<\/strong>, their importance, use cases, and syntax. We will also look at best practices to use them in an AWS account.<\/p>\n<h2 id=\"aws-organizations\">AWS Organizations<\/h2>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/organizations\/latest\/userguide\/orgs_getting-started_concepts.html?ref=devopscube.com\">AWS Organizations<\/a> is an account management service that helps to manage multiple AWS accounts centrally.<\/p>\n<p>Typically every organization would have different <strong>organization units (OU)<\/strong> and every OU may have different teams and every team has its own AWS accounts (member accounts).<\/p>\n<p>AWS Organization is capable of creating Organizational Units (OUs). These organizational units will maintain the member accounts.<\/p>\n<p>The following image shows root, OUs, and member accounts.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/aws-organization-heirarchy-1.gif\" class=\"kg-image\" alt=\"AWS organizational units example\" loading=\"lazy\"><\/figure>\n<h2 id=\"aws-tags\">AWS Tags<\/h2>\n<p><strong>AWS tags<\/strong> are small pieces of metadata that can be attached to various AWS resources, such as Elastic Compute Cloud (EC2) instances, Simple Storage Service (S3) buckets, and Relational Database Service (RDS) instances.<\/p>\n<p>A tag has two parts, one is <code>tag key<\/code> and the other one is optional which is <code>tag value<\/code>.<\/p>\n<p>Here is an example of tags attached to an ec2 instance.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-23-31.png\" class=\"kg-image\" alt=\"aws tags example\" loading=\"lazy\" width=\"568\" height=\"377\"><\/figure>\n<h2 id=\"resource-tagging-and-its-importance\">Resource Tagging and its Importance<\/h2>\n<p>Let&#8217;s look at why resource tagging is important in AWS.<\/p>\n<ol>\n<li><strong>Organize Resources: <\/strong>Organize AWS resources with certain categories. For example, if there are different environments, allocating tags separately allows users to easily identify their resources in a large organization.<\/li>\n<li><strong>Cost Tracking<\/strong>: Track the costs category-wise with the related tags. It is one of the very important practices to track costs in cloud computing, and it also helps to create budget plans.<\/li>\n<li><strong>Security Compliance:<\/strong> Through tags, policies can be attached to restrict the provisioning of certain resources. For example, enforcing tag value compliance for a particular resource ensures that without the proper key, no one can provision that resource.<\/li>\n<\/ol>\n<p>Here are some best practices to follow,<\/p>\n<ol>\n<li><strong>Tagging Policies:<\/strong> To prevent untagged resource provisioning, attach a tag policy that enforces compliance with tagging requirements.<\/li>\n<li><strong>Minimal Tags:<\/strong> Avoid creating excessive tags; instead keep them short and meaningful. This approach helps to easily understand their usage and avoids unnecessary confusion.<\/li>\n<li><strong>Tag Review<\/strong>: Periodically review the tags. and update them as per the changes in requirements. This practice will improve the accuracy of tracking resources.<\/li>\n<\/ol>\n<h2 id=\"what-is-aws-tag-policy\">What is AWS Tag Policy?<\/h2>\n<p>AWS Organizations Tag Policy is used to <strong>standardize AWS resource tagging<\/strong>. The Tag Policy applies certain rules to resources when they are created.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-16-32.png\" class=\"kg-image\" alt=\"AWS Organization tag policy\" loading=\"lazy\" width=\"612\" height=\"344\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-16-32.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-16-32.png 612w\"><\/figure>\n<p>All policies applied to organizational units are applied to all organizational accounts.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-15-26.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"610\" height=\"343\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-15-26.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-15-26.png 610w\"><\/figure>\n<h2 id=\"tag-policy-syntax\">Tag Policy Syntax<\/h2>\n<p>The tag policy is structured in a simple JSON format. so it is easy to create and manage rules.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-17-27.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"612\" height=\"344\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-17-27.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-17-27.png 612w\"><\/figure>\n<h3 id=\"tag-key-capitalization-compliance\">Tag key capitalization compliance<\/h3>\n<p>Tag keys are case-sensitive. If tag key compliance is not enabled, it will automatically take the tag key as lowercase. Alternatively, if any kind of capitalization compliance is specified in the parent policy, it will be applied to the other policies as well.<\/p>\n<p>So, to avoid these confusions, enable tag key capitalization compliance. This means that wherever the tag key is mentioned, the exact same name has to be given. For example, here the tag key name is <code>CostCenter<\/code> , and if try to launch a resource with the tag key <code>COSTCENTER<\/code> or <code>costcenter<\/code> , it will show an error message.<\/p>\n<h3 id=\"tag-value-compliance\">Tag value compliance<\/h3>\n<p>Tag values are subject to specific rules set for tag keys. They represent the actual value that can be seen after the resource has been created. often serving as the resource name. If not enable tag value compliance, can give any value for the tag key.<\/p>\n<p>However, in this case, enabled tag value compliance for the <code>CostCenter<\/code> tag key with the value <code>techiescamp-commerce.<\/code> Therefore, when using the <code>CostCenter<\/code> tag key, only the <code>techiescamp-commerce<\/code> tag value can be used; Otherwise, the resource won\u2019t be created.<\/p>\n<blockquote><p><strong>Note:<\/strong> You can also use <a href=\"https:\/\/aws.amazon.com\/config\/?ref=devopscube.com\" rel=\"noreferrer noopener\">AWS Config<\/a> service for Tag complinace. The only difference is, AWS config helps you remediate the tag compliance. You cannot enforce rules using config service. However, you can monitors existing tags and checks if they comply with the rules you set.<\/p><\/blockquote>\n<h3 id=\"resource-types-to-enforce\">Resource types to enforce<\/h3>\n<p>Specify certain resource types for this tagging strategy so that the rules only apply to those resources. By enabling the <strong>Prevent non-compliant operation<\/strong> feature, ensure that for those particular resources, a specific tag key and tag value must be provided during launch.<\/p>\n<p>In this case, multiple resource types are mentioned, for example: <code>ec2:instance, ec2:security-group, elasticfilesystem:*, lambda:*, etc.<\/code>Therefore, when launching a resource, the proper tag key and tag value must be provided.<\/p>\n<blockquote><p><strong>Note:<\/strong> For <code>enforce_for<\/code>, for some services, can use <code>all resources<\/code>. For example, to enable tag policy in all resources for <strong>AWS Backup<\/strong>, can use <code>backup:*<\/code>. However, it is not possible to enable tag policy for all resources in <strong>Amazon EC2.<\/strong> To know more about the supported services, <a href=\"https:\/\/docs.aws.amazon.com\/organizations\/latest\/userguide\/orgs_manage_policies_supported-resources-enforcement.html?ref=devopscube.com\">visit the official documentation.<\/a><\/p><\/blockquote>\n<h2 id=\"automating-tag-policies-using-terraform\">Automating Tag Policies Using Terraform<\/h2>\n<p>It is always better to manage the tag policies as part of the <a href=\"https:\/\/devopscube.com\/infrastructure-as-code-configuration-management\/\">IaC<\/a>.<\/p>\n<p>I have created a step-by-step terraform guide to configure tag policies for an AWS account.<\/p>\n<p>Checkout <a href=\"https:\/\/devopscube.com\/aws-tag-policy-terraform\/\" rel=\"noreferrer noopener\">AWS Tag Policy Configuration Using Terraform<\/a><\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>As <a href=\"https:\/\/devopscube.com\/become-devops-engineer\/\">Devops Engineers<\/a>, it is very important to maintain AWS resources with recommended tags from the organization.<\/p>\n<p>With tag policies, you can <strong>enforce organization-wide tags<\/strong> for all the supported AWS resources. This ensures no resources get deployed without required tags.<\/p>\n<p>Furthermore, with tools like <strong>Checkov<\/strong>, we can implement tag checks before the IaC code gets committed to the main branch.<\/p>\n<p>Also, check <a href=\"https:\/\/devopscube.com\/things-to-do-for-securing-aws-account\/\">AWS security tips<\/a> if you are getting started with AWS.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/aws-tag-policy\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Tag Policy Explained For Beginners \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/aws-tag-policy\/<\/p>\n","protected":false},"author":1,"featured_media":1089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/1088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1088"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/1088\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/1089"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}