Tagging strategy and tag policies: ownership, cost allocation and enforcement
Design a small mandatory tag set for Harbourline, standardise it with Organizations tag policies, enforce it at creation time with SCPs, Config rules and CDK, activate it for cost allocation, and audit coverage with a C# tool.
Assumes: .NET 10 LTS · AWS SDK for .NET v4 · AWS CLI v2 · CDK v2 (Amazon.CDK.Lib 2.277.0) · Terraform AWS provider v6 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Choose a mandatory tag set (owner, cost centre, application, environment, data classification) and explain what each tag is used for.
- Write an AWS Organizations tag policy, attach it to an OU, and explain exactly what it does and does not enforce.
- Combine four layers of enforcement: tag policy (value standardisation), SCP (deny create without tag), AWS Config rule (detect missing tags) and infrastructure as code (apply tags by default).
- Activate user-defined tags as cost allocation tags in the management account, and explain why activation is not retroactive by default.
- Audit tag coverage with the Resource Groups Tagging API from C#, and explain the blind spot that API has.
Prerequisites
- Module 15 overview and the multi-account structure it describes (management account, OUs, member accounts).
- Boundaries: SCPs, RCPs and resource policies for how an SCP deny is evaluated.
- AWS Config: recording, rules, remediation and conformance packs for Config rules.
- Accounts and Organizations for the basics of an organisation.
- Tools: AWS CLI v2 with the
learn-sandboxSSO profile and, for the tag policy and cost allocation steps, access to the management account of your sandbox organisation. .NET 10 SDK for the audit tool.
Why this matters in banking
Three different people ask three questions that all depend on tags.
- Finance asks: "Which business line spent the 41,000 dollars that appeared under Amazon EC2 last month?" Without a
CostCentertag the answer is "somebody in the payments account" and the chargeback conversation goes nowhere. - Security operations asks: "This S3 bucket has customer data in it. Who owns it, and is it classified as confidential?" At 02:00 during an incident, a bucket with no
Ownerand noDataClassificationtag costs real minutes. - The auditor asks: "Show me that every production resource that stores personal data is identified as such." A tag set that is applied by code and checked automatically is much stronger evidence than a spreadsheet.
Tags are weak by design. They are free-text labels that anyone with the right permission can change, with case-sensitive keys and values and no built-in "this tag is required" switch. A bank therefore treats tagging as a small control system: a standard, a way to apply it, a way to detect gaps and a way to stop the worst gaps. This lesson builds that system.
Tags are not a security boundary on their own
Tags can drive access decisions (attribute-based access control with aws:ResourceTag and aws:PrincipalTag), but a cost tag such as CostCenter should never be what stops a developer reading a payments database. If a tag is used in an IAM or SCP condition, protect who can change it with an SCP of its own. Keep cost-allocation tags and access-control tags as separate sets, and have your security team review any policy that trusts a tag.
The idea in plain language
A tag is a key and a value attached to a resource, such as CostCenter = CC-4410. Keys and values are both case sensitive: costcenter, CostCenter and Costcenter are three different keys, and your cost report will show three different columns. Most of the pain in real tagging programmes comes from that single fact.
A good tagging strategy answers four questions:
- Which tags are mandatory? Keep the list short, because every mandatory tag is a thing people will get wrong. Five is a good ceiling.
- What are the allowed values? A free-text
Environmenttag gives youprod,Prod,productionandPRD. A list of allowed values gives you one. - How do tags get onto resources? Ideally never by hand: infrastructure as code applies them, and the pipeline fails when they are missing.
- What happens when they are missing? Detect, report, nag the owner, and for the most important resource types prevent creation.
Analogy: tags are the asset labels in a bank branch. Every laptop has a barcode sticker with an owner and a cost centre. The facilities policy (tag policy) says what the stickers must look like; the purchasing rule (SCP) says you cannot take delivery of a laptop without a sticker; the quarterly stock-take (Config) finds the ones that slipped through; and the supplier who prints the stickers before the laptop arrives (infrastructure as code) means almost none slip through at all.
Harbourline's tag standard
| Tag key | Example value | Used for | Allowed values |
|---|---|---|---|
CostCenter | CC-4410 | Cost allocation, showback and chargeback | Pattern CC- plus four digits, maintained by Finance |
Application | accounts-api | Grouping resources by system, incident response, FinOps reports | Registered application names |
Environment | prod | Separating production from the rest | prod, staging, dev, sandbox, learn |
Owner | payments-platform-team | Who to contact, who approves a change | A team name from the directory, not a person's email |
DataClassification | confidential | Evidence for GDPR / UK GDPR data mapping; drives encryption and retention checks | public, internal, confidential, restricted |
The lab convention in this course's CONVENTIONS.md (Project, Lab, Environment, Owner) is the learner-sandbox version of the same idea. In a real bank, the standard above would be the starting point and security, finance and platform teams would agree it together.
Two design rules save pain later:
- Use team names, not people's names, for
Owner. People move teams. A tag that names a person is stale within a year, and a personal email address is also personal data sitting in a billing report. - Do not put anything sensitive in a tag. Tags appear in billing exports, in the console and in many logs. Never put a customer identifier, a secret or a free-text reason into a tag value.
What problem the AWS service solves
AWS offers several tools. Each does one job, and none does all of them.
| Tool | What it does | What it does not do |
|---|---|---|
| Tag policy (AWS Organizations) | Defines the tag keys, capitalisation and allowed values for the organisation, an OU or an account; reports non-compliant tags; optionally blocks non-compliant tagging operations for chosen resource types | Does not make a tag mandatory. Resources with no tag, and tags not defined in the policy, are not evaluated |
| SCP deny with a tag condition | Blocks creation of a resource when a required tag is not in the request | Only works for API actions that support tagging at creation; can break automation that tags after creation |
AWS Config required-tags rule | Detects resources missing required tags and can trigger remediation | Detects after the fact; limited to the resource types Config records and the rule supports |
| Infrastructure as code defaults | Applies tags to everything in a stack (CDK Tags.Of, Terraform default_tags) | Only covers resources created by that code |
| Cost allocation tag activation | Makes a tag a column in Cost Explorer, Budgets and billing exports | Applies from the activation date; does not fix resources that are untagged |
| Resource Groups Tagging API / Tag Editor | Searches and bulk-edits tags across services and Regions; produces compliance reports against tag policies | Returns resources that have, or have previously had, tags; a resource that was never tagged may not show up |
Honest limitations to remember:
- Tag policies need all features enabled in the organisation and are managed from the management account (or a delegated administrator, ⚠ VERIFY current delegation support).
- Not every resource type supports tags, and not every one supports enforcement by a tag policy. The enforcement list of supported resource types is service-by-service. ⚠ VERIFY the resource types you rely on in the Organizations documentation.
- Tag limits: a resource normally holds up to 50 user-defined tags, keys up to 128 characters and values up to 256, and the
aws:prefix is reserved. ⚠ VERIFY, because some services have their own limits. - Not every charge is taggable. Data transfer, support fees, taxes and some shared services appear in the bill with no tag. Plan a "shared and untagged" bucket in your showback report. The next lessons cover how to allocate it.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
| Azure tags on resources and resource groups | AWS tags on resources only | There is no resource group that tags its children; use IaC default tags or a tag policy |
Azure Policy Require a tag on resources (deny) | SCP with a Null condition on aws:RequestTag/... | The SCP only works for actions that accept tags on create; Azure Policy works at resource-provider level |
Azure Policy Inherit a tag from the resource group (modify) | No direct equivalent. IaC default tags or a Config auto-remediation | AWS never silently rewrites a resource for you |
| Azure Policy allowed values for a tag | Organizations tag policy tag_value list | Tag policy also standardises key capitalisation |
| Tag inheritance in Cost Management | Cost allocation tags and cost categories; account-level tags in the organisation | Activate tags first; a cost category can group by account, tag or service |
| Azure Resource Graph for tag queries | Resource Explorer, Tag Editor, Resource Groups Tagging API, Config advanced queries | Different tools for different services and Regions |
| Management group policy assignment | Tag policy attached to root, OU or account | Policies inherit down the OU tree and merge into an effective policy |
Architecture
Security-boundary view: the management account owns the policies and cost tag activation, workload accounts cannot detach an SCP or tag policy, and the central reporting happens in a security or FinOps account with read-only access. A tag policy is only as strong as the people who can edit it, so restrict organizations:*Policy* actions to a small platform role.
Step-by-step implementation
Agree the standard
Write the five tags, their allowed values and the owner of each list into a short document. Get Finance (for CostCenter) and Security (for DataClassification) to approve it. This takes longer than the technical steps and matters more.
Enable tag policies and create the policy
In the management account, enable the TAG_POLICY policy type on the organisation root, then create a tag policy that defines the five keys with allowed values. Start with no enforcement: let the compliance report show you how bad things are.
Attach to a test OU first
Attach the policy to the Sandbox OU (or one test account), run the compliance report and look at the noise. Only after the results make sense attach it to Workloads.
Apply tags from code
Set default tags in CDK and Terraform so new resources are born compliant. Add a pipeline check that fails the build when a required tag is missing.
Add the detection layer
Deploy the Config required-tags rule (or conformance pack equivalent) across accounts so gaps in click-ops resources are found.
Add the prevention layer, carefully
For a small number of high-value resource types (EC2 instances, RDS databases, S3 buckets), add an SCP that denies creation without CostCenter and Owner. Test it in Sandbox first, because an SCP that blocks a service that tags after creation will break deployments.
Activate cost allocation tags
Activate CostCenter, Application, Environment and Owner as cost allocation tags in the management account. From that point they are columns in Cost Explorer, Budgets and the exports covered in later lessons.
Report and chase
Run the audit tool weekly, send each owner their untagged resources, and track the percentage of cost that is tagged. A common target is above 90 percent of spend attributable to a cost centre. ⚠ VERIFY your own firm's target.
AWS Console instructions
- Enable tag policies: Console (management account) → AWS Organizations → Policies → Tag policies → Enable tag policies.
- Create a policy: Tag policies → Create policy. Use the visual editor to add each tag key and allowed values, or paste JSON. In the editor, the checkbox Prevent non-compliant operations for this tag with a resource type list is the enforcement switch. Leave it off at first.
- Attach: open the policy → Targets → Attach policy → choose the OU or account.
- See the effective policy: Organizations → AWS accounts → select an account → Policies → Effective tag policy (wording ⚠ VERIFY).
- Compliance report: Console → Resource Groups & Tag Editor → Tag policies (in the account) for one account, or generate an organisation report from the management account. ⚠ VERIFY the console path, which has moved over time.
- Activate cost allocation tags: Console → Billing and Cost Management → Cost allocation tags → User-defined cost allocation tags, select the keys and choose Activate. A key only appears in this list after it has been used on a resource in an account of the organisation. Activation can take up to 24 hours to take effect. ⚠ VERIFY the delay.
AWS CLI
# 1) Find the organisation root ID (run in the management account).
aws organizations list-roots --profile learn-mgmt --query 'Roots[0].Id' --output text
# 2) Enable the tag policy type on the root. Replace r-abcd with your root ID.
aws organizations enable-policy-type --root-id r-abcd --policy-type TAG_POLICY --profile learn-mgmt
# 3) Create the policy from a JSON file (shown below).
aws organizations create-policy \
--name hl-tag-standard \
--description "Harbourline mandatory tag keys and values" \
--type TAG_POLICY \
--content file://tag-policy.json \
--profile learn-mgmt
# 4) Attach it to an OU (replace the policy ID and OU ID).
aws organizations attach-policy --policy-id p-abc123 --target-id ou-abcd-11111111 --profile learn-mgmt
# 5) Show the policy that actually applies to one account (inheritance merged).
aws organizations describe-effective-policy --policy-type TAG_POLICY \
--target-id 111122223333 --profile learn-mgmt
# 6) Ask the Tagging API how many resources are non-compliant with the tag policy.
aws resourcegroupstaggingapi get-compliance-summary \
--group-by TARGET_ID --region us-east-1 --profile learn-sandbox
# 7) Start an organisation-wide compliance report into an S3 bucket (management account).
aws resourcegroupstaggingapi start-report-creation \
--s3-bucket hl-tag-reports-111122223333 --region us-east-1 --profile learn-mgmt
# 8) Activate cost allocation tags (management account).
aws ce update-cost-allocation-tags-status \
--cost-allocation-tags-status TagKey=CostCenter,Status=Active TagKey=Owner,Status=Active \
TagKey=Application,Status=Active TagKey=Environment,Status=Active \
--region us-east-1 --profile learn-mgmt
# 9) Check which tags are active.
aws ce list-cost-allocation-tags --status Active --region us-east-1 --profile learn-mgmtThe tag policy for step 3:
{
"tags": {
"CostCenter": {
"tag_key": { "@@assign": "CostCenter" },
"tag_value": { "@@assign": ["CC-4410", "CC-4420", "CC-5100", "CC-9000"] }
},
"Environment": {
"tag_key": { "@@assign": "Environment" },
"tag_value": { "@@assign": ["prod", "staging", "dev", "sandbox", "learn"] },
"enforced_for": { "@@assign": ["ec2:instance"] }
},
"DataClassification": {
"tag_key": { "@@assign": "DataClassification" },
"tag_value": { "@@assign": ["public", "internal", "confidential", "restricted"] }
},
"Owner": {
"tag_key": { "@@assign": "Owner" }
},
"Application": {
"tag_key": { "@@assign": "Application" }
}
}
}Reading it: each top-level entry names a tag. @@assign sets a value outright (child policies in the OU tree can use @@append or @@remove to modify what a parent set). tag_value restricts allowed values. enforced_for makes a non-compliant tagging operation fail, here only for EC2 instances. Wildcards are supported in some places, such as ec2:*, and several services support enforcement while many do not. ⚠ VERIFY the supported types before you rely on enforcement. Note that Owner and Application define only the key (and its capitalisation) with no value list, which is correct for free-text values.
Infrastructure as Code
This stack, deployed in the management account, creates the tag policy, an SCP that denies creating EC2 instances and RDS databases without the CostCenter and Owner tags, and activates cost allocation tags. A second snippet shows the workload side: default tags for every resource in the app. L1 constructs are used for Organizations, and a custom resource calls Cost Explorer because Amazon.CDK.Lib 2.277.0 has no L1 construct for cost allocation tags (the stack compiles against that version; the custom resource runs only on deploy). ⚠ VERIFY runtime behaviour; the Terraform tab has a native resource
using System.Collections.Generic;
using Amazon.CDK;
using Amazon.CDK.AWS.Organizations;
using Amazon.CDK.CustomResources;
using Constructs;
namespace Harbourline.Governance.Infra;
public sealed class TagGovernanceStack : Stack
{
public TagGovernanceStack(Construct scope, string id, string workloadsOuId, IStackProps? props = null)
: base(scope, id, props)
{
// Applies Project/Environment/Owner to the stack's own taggable resources.
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
// --- Tag policy: keys, capitalisation and allowed values -----------------------------
var tagPolicy = new Dictionary<string, object>
{
["tags"] = new Dictionary<string, object>
{
["CostCenter"] = new Dictionary<string, object>
{
["tag_key"] = new Dictionary<string, object> { ["@@assign"] = "CostCenter" },
["tag_value"] = new Dictionary<string, object>
{
["@@assign"] = new[] { "CC-4410", "CC-4420", "CC-5100", "CC-9000" },
},
},
["Environment"] = new Dictionary<string, object>
{
["tag_key"] = new Dictionary<string, object> { ["@@assign"] = "Environment" },
["tag_value"] = new Dictionary<string, object>
{
["@@assign"] = new[] { "prod", "staging", "dev", "sandbox", "learn" },
},
["enforced_for"] = new Dictionary<string, object> { ["@@assign"] = new[] { "ec2:instance" } },
},
["Owner"] = new Dictionary<string, object>
{
["tag_key"] = new Dictionary<string, object> { ["@@assign"] = "Owner" },
},
},
};
new CfnPolicy(this, "TagStandard", new CfnPolicyProps
{
Name = "hl-tag-standard",
Description = "Harbourline mandatory tag keys and values",
Type = "TAG_POLICY",
Content = tagPolicy,
TargetIds = new[] { workloadsOuId },
});
// --- SCP: deny creating key resource types without CostCenter and Owner ---------------
var scp = new Dictionary<string, object>
{
["Version"] = "2012-10-17",
["Statement"] = new object[]
{
new Dictionary<string, object>
{
["Sid"] = "DenyEc2WithoutMandatoryTags",
["Effect"] = "Deny",
["Action"] = new[] { "ec2:RunInstances" },
["Resource"] = new[] { "arn:aws:ec2:*:*:instance/*" },
["Condition"] = new Dictionary<string, object>
{
["Null"] = new Dictionary<string, object>
{
["aws:RequestTag/CostCenter"] = "true",
},
},
},
new Dictionary<string, object>
{
["Sid"] = "DenyRdsWithoutOwner",
["Effect"] = "Deny",
["Action"] = new[] { "rds:CreateDBInstance", "rds:CreateDBCluster" },
["Resource"] = "*",
["Condition"] = new Dictionary<string, object>
{
["Null"] = new Dictionary<string, object>
{
["aws:RequestTag/Owner"] = "true",
},
},
},
},
};
new CfnPolicy(this, "RequireTagsScp", new CfnPolicyProps
{
Name = "hl-require-mandatory-tags",
Description = "Deny create without CostCenter / Owner (Workloads OU). Test in Sandbox first.",
Type = "SERVICE_CONTROL_POLICY",
Content = scp,
TargetIds = new[] { workloadsOuId },
});
// --- Cost allocation tags: activate once the keys exist on resources -------------------
// There is no L1 construct for this in Amazon.CDK.Lib 2.277.0 (checked at compile time),
// so a custom resource calls the Cost Explorer API. Cost Explorer's endpoint is in us-east-1.
new AwsCustomResource(this, "ActivateCostTags", new AwsCustomResourceProps
{
OnCreate = new AwsSdkCall
{
Service = "CostExplorer",
Action = "updateCostAllocationTagsStatus",
Region = "us-east-1",
Parameters = new Dictionary<string, object>
{
["CostAllocationTagsStatus"] = new object[]
{
new Dictionary<string, object> { ["TagKey"] = "CostCenter", ["Status"] = "Active" },
new Dictionary<string, object> { ["TagKey"] = "Application", ["Status"] = "Active" },
new Dictionary<string, object> { ["TagKey"] = "Environment", ["Status"] = "Active" },
new Dictionary<string, object> { ["TagKey"] = "Owner", ["Status"] = "Active" },
},
},
PhysicalResourceId = PhysicalResourceId.Of("hl-cost-allocation-tags"),
},
Policy = AwsCustomResourcePolicy.FromStatements(new[]
{
new Amazon.CDK.AWS.IAM.PolicyStatement(new Amazon.CDK.AWS.IAM.PolicyStatementProps
{
Actions = new[] { "ce:UpdateCostAllocationTagsStatus" },
Resources = new[] { "*" },
}),
}),
});
}
}On the workload side, one line in the CDK app applies default tags to every taggable construct, which is how resources are born compliant:
using Amazon.CDK;
using Harbourline.Accounts.Infra;
var app = new App();
var stack = new AccountsApiStack(app, "hl-accounts-api-prod");
// Everything under the app inherits these tags. Values come from CI variables, never from code.
Amazon.CDK.Tags.Of(app).Add("CostCenter", "CC-4410");
Amazon.CDK.Tags.Of(app).Add("Application", "accounts-api");
Amazon.CDK.Tags.Of(app).Add("Environment", "prod");
Amazon.CDK.Tags.Of(app).Add("Owner", "payments-platform-team");
Amazon.CDK.Tags.Of(app).Add("DataClassification", "confidential");
app.Synth();Complete code
A C# console tool that audits tag coverage in one account and Region using the Resource Groups Tagging API. For each resource it checks the five mandatory keys and prints a summary and a CSV of gaps. It uses only read permissions (tag:GetResources).
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<!-- Look up exact 4.x versions at https://api.nuget.org/v3-flatcontainer/<id>/index.json -->
<PackageReference Include="AWSSDK.ResourceGroupsTaggingAPI" Version="4.*" />
</ItemGroup>
</Project>using System.Text;
using Amazon;
using Amazon.ResourceGroupsTaggingAPI;
using Amazon.ResourceGroupsTaggingAPI.Model;
// Mandatory keys from the Harbourline tag standard.
string[] required = ["CostCenter", "Application", "Environment", "Owner", "DataClassification"];
string profileRegion = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
using var client = new AmazonResourceGroupsTaggingAPIClient(RegionEndpoint.GetBySystemName(profileRegion));
var gaps = new List<(string Arn, string Service, string[] Missing)>();
int total = 0;
string? token = null;
do
{
var response = await client.GetResourcesAsync(new GetResourcesRequest
{
ResourcesPerPage = 100,
PaginationToken = token,
});
foreach (var mapping in response.ResourceTagMappingList ?? [])
{
total++;
var keys = (mapping.Tags ?? []).Select(t => t.Key).ToHashSet(StringComparer.Ordinal);
var missing = required.Where(r => !keys.Contains(r)).ToArray();
if (missing.Length > 0)
{
// ARN format: arn:partition:service:region:account:resource
var service = mapping.ResourceARN.Split(':').ElementAtOrDefault(2) ?? "unknown";
gaps.Add((mapping.ResourceARN, service, missing));
}
}
token = string.IsNullOrEmpty(response.PaginationToken) ? null : response.PaginationToken;
}
while (token is not null);
Console.WriteLine($"Region {profileRegion}: {total} tagged-or-previously-tagged resources checked.");
Console.WriteLine($"Resources missing at least one mandatory tag: {gaps.Count} ({(total == 0 ? 0 : 100.0 * gaps.Count / total):F1}%)");
Console.WriteLine();
foreach (var group in gaps.GroupBy(g => g.Service).OrderByDescending(g => g.Count()))
{
Console.WriteLine($" {group.Key,-20} {group.Count(),5} resources with gaps");
}
var csv = new StringBuilder("arn,service,missing\n");
foreach (var (arn, service, missing) in gaps)
{
csv.Append('"').Append(arn).Append("\",").Append(service).Append(",\"").Append(string.Join(';', missing)).Append("\"\n");
}
await File.WriteAllTextAsync("tag-gaps.csv", csv.ToString());
Console.WriteLine("\nWrote tag-gaps.csv");Code explained line by line
string[] required = [...]is the standard as data. In a real tool you would load it from the same JSON as the tag policy so the two cannot drift.- The client is created for one Region. The Tagging API is regional, so a full audit loops over enabled Regions. Remember that your region-restricting SCP means most Regions are empty.
- The
do ... whileloop followsPaginationToken. The API returns a page and a token, and an empty token means the last page. - In SDK v4 a missing collection is
nullrather than an empty list, so the code uses?? []. keysis a case-sensitive set (StringComparer.Ordinal), matching how AWS treats tag keys. A resource taggedcostcenteris reported as missingCostCenter, which is exactly what you want to surface.- The service name comes from splitting the ARN on
:. Index 2 is the service segment of every ARN. - The CSV is the artefact you send to owners. Keep it out of source control, because ARNs include account IDs.
The blind spot. GetResources returns resources that are tagged or were previously tagged. A resource that has never had a tag may not appear at all, so a clean report from this tool is not proof of full coverage. Pair it with the Config required-tags rule or a Config advanced query, which reads the recorded inventory, and with Cost Explorer's "no tag" group for the spending view.
Security considerations
⚠ Learning shortcut — not for production
The lab attaches the policies to a single OU, uses a short allowed-values list typed into the policy, and runs the audit with your own SSO session. In production, the allowed values for CostCenter come from Finance's master data and are synchronised by a pipeline; policy changes go through pull request review with a security approver; the audit runs as a read-only role from a security or FinOps account; and the SCP is staged through Sandbox, then Dev, then Production with a break-glass role excluded by an ArnNotLike condition on aws:PrincipalArn.
- Protect the tags that carry meaning. If any policy uses
aws:ResourceTag/DataClassification, add a deny fortag:TagResources,ec2:CreateTagsand similar actions that change that key unless the caller is a governance role. - SCP blast radius. A deny on
ec2:RunInstanceswith a tag condition also blocks Auto Scaling, EMR and Batch launches that do not pass tags in the launch request. Test those paths, or exempt service-linked roles. - Privacy. A tag value is metadata visible to anyone with billing or tag read access. Do not use customer names, account numbers or personal emails. For UK GDPR data-mapping, a
DataClassificationtag is a helpful pointer, but your data inventory (record of processing activities) remains a legal and compliance document owned by your data protection officer. - Auditability. Tag policy changes and tag changes appear in CloudTrail (
CreatePolicy,AttachPolicy,TagResourceevents). Keep them in the central log archive covered earlier in this module.
Banking use case
Harbourline's finance team wants monthly showback per business line. The platform team publishes the five-tag standard, attaches the tag policy to the Workloads OU in report-only mode and deploys the Config rule everywhere. The first report finds 38 percent of EC2 and RDS resources missing CostCenter. Most are created by an old Terraform module with no default tags, and a few are console-created test instances. Within a month the module is fixed, the owners of the strays are chased, and the SCP is switched on for EC2 and RDS creation in Workloads. The tagged-spend percentage in the weekly FinOps report moves from 62 to 94, and the monthly showback email becomes automatic. The same tags then give security operations an owner to page for any bucket flagged by Macie.
Common mistakes
- Treating the tag policy as a requirement. It is not: untagged resources are ignored. Add the SCP, Config rule and IaC layers.
- Turning on enforcement for everything on day one. Pipelines and services that tag after creation start failing. Report first, enforce later and only for chosen types.
- Forgetting to activate cost allocation tags. Tags exist on resources but the cost report has no column for them. Activation is a separate step in the management account.
- Expecting activation to fix history. By default it applies from activation onward. AWS has added a backfill capability for cost allocation tags, but check the current documentation and limits. ⚠ VERIFY
- Mixed capitalisation.
Environment=ProdandEnvironment=prodsplit a cost report. Use the allowed values list. - Tagging people. Personal emails in
Ownerage badly and leak personal data into billing exports. - Letting IaC and manual tags fight. Terraform removes tags it does not know about on the next apply unless you use
default_tagsandignore_tagscarefully.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
PolicyTypeNotEnabledException when creating a tag policy | The TAG_POLICY type is not enabled on the root | Run enable-policy-type first; check that all features are enabled in the organisation |
| Tag key not offered in Cost allocation tags | The key has not yet been used on a resource in the organisation, or you are in a member account | Tag one resource, wait, and activate from the management account |
| Cost Explorer shows no values for an activated tag | Activation takes effect up to 24 hours later and only applies to usage from then on | Wait, check the date range, and consider the backfill option ⚠ VERIFY |
| Tagging a resource fails with a tag policy error | The enforced_for setting blocked a non-compliant value | Use a value from the policy, or remove enforcement for that resource type |
| SCP blocks Auto Scaling or a managed service launching instances | The service launches resources without passing the required tag in the create request | Tag via the launch template, or carve the service-linked role out of the SCP |
| Audit tool reports zero resources in a busy account | Wrong Region, or the resources have never been tagged | Check AWS_REGION, then use Config advanced queries for the real inventory |
| Compliance report shows noise from old resources | The policy was attached to a broad OU before cleaning up | Scope to a test OU, fix, then widen |
Cost and cleanup
Cost: free. Organizations, tag policies and SCPs have no charge. Activating cost allocation tags has no charge. The Resource Groups Tagging API has no charge. AWS Config rules cost money per evaluation and per configuration item recorded, so run the Config part only for a short session and see the Config lesson for the pricing detail. The compliance report stores a small CSV in S3 (cents). Cost Explorer API calls made from the CLI are charged a small amount per request. ⚠ VERIFY the current rate.
Teardown (management account), in this order:
# Detach the policies from the OU, then delete them.
aws organizations detach-policy --policy-id p-abc123 --target-id ou-abcd-11111111 --profile learn-mgmt
aws organizations delete-policy --policy-id p-abc123 --profile learn-mgmt
# Optional: switch the policy type off again.
aws organizations disable-policy-type --root-id r-abcd --policy-type TAG_POLICY --profile learn-mgmt
# Deactivate cost allocation tags if this was only a lab.
aws ce update-cost-allocation-tags-status \
--cost-allocation-tags-status TagKey=CostCenter,Status=Inactive TagKey=Owner,Status=Inactive \
--region us-east-1 --profile learn-mgmt
# Empty and delete the report bucket, then delete the Config rule if you deployed it.
aws s3 rb s3://hl-tag-reports-111122223333 --force --profile learn-mgmt
aws configservice delete-config-rule --config-rule-name hl-required-tags --profile learn-sandbox
# Confirm nothing from the lab remains.
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab \
--region us-east-1 --profile learn-sandbox --query 'ResourceTagMappingList[].ResourceARN'Exercises
- 🟢 Guided: write the five-tag standard for your own portfolio project, create a tag policy with allowed values for
Environment, attach it to a Sandbox OU and rundescribe-effective-policyon a sandbox account. - 🟡 Challenge: add a CDK Aspect or a Terraform
preconditionthat fails the build when a stack has noCostCenter. Then explain why the SCP and the pipeline check are both needed. - 🔴 Live problem: finance says 30 percent of last month's EC2 and RDS spend is "unattributed", and the SCP you propose would block the data-science team's Auto Scaling groups. Write a one-page plan covering detection, a rollout order, an exception for the data-science team and how you will measure improvement.
Assignment
Produce a governance/tagging/ folder for your portfolio repository containing the tag standard (Markdown), the tag policy JSON, the SCP JSON with a test plan, the CDK or Terraform code, and the audit tool. Add a short README explaining which layer catches which failure.
Solutions
Create a policy with Environment allowed values prod, staging, dev, sandbox, learn. Enable the policy type, create the policy, attach it, then run describe-effective-policy --policy-type TAG_POLICY --target-id <account>. The effective policy should show the same tag with the allowed values merged from every parent. This proves inheritance: a policy on the root and a policy on an OU combine, and @@assign in the child replaces the parent's setting for that field. The key learning is that nothing is enforced yet: tag a test bucket Environment=Prod and the compliance report flags it, but the bucket still exists.
A CDK Aspect implements IAspect.Visit(IConstruct node) and walks the construct tree. For taggable constructs, check the rendered tags (for example via TagManager.IsTaggable(node) and the tag manager's rendered tags) and call Annotations.Of(node).AddError("Missing CostCenter") when the key is absent. Annotation errors fail cdk synth, so the pipeline stops. In Terraform, a check block or a precondition on a terraform_data resource can assert that var.cost_center matches the allowed pattern. ⚠ VERIFY the Aspect API names in the version you use.
Both are needed because they catch different people. The pipeline check protects code you control and fails fast with a clear message. The SCP protects against the console, the CLI, third-party tools and other teams' pipelines that do not run your check. An SCP is the last-line control, the pipeline check is the friendly one.
Knowledge check
Answer: The instance is created and the tag policy does not flag it. Tag policies evaluate only tags that exist and are defined in the policy, and untagged resources are not evaluated. To require the tag, use an SCP (Null condition on aws:RequestTag/CostCenter), a Config required-tags rule, or IaC checks.
Answer: Activation applies from the activation date by default, and can take up to 24 hours to show. Past usage does not gain a column unless a backfill option is used. ⚠ VERIFY the current backfill rules. The tag must also be applied to resources, and activation happens in the management account.
Answer: It checks the tags supplied in the create or tag request, so it is useful for requiring tags at creation. It does not check tags already on a resource (that is aws:ResourceTag), and it only works for actions that support tagging on create. Using ResourceTag to require a tag on create would not work because the resource does not exist yet.
Answer: Because cost tags are edited by many people and teams for convenience, while a tag that grants access is a security control. Mixing them means a billing clean-up could accidentally grant or remove access. Use distinct keys, and protect the access-control tag keys with an SCP.
Answer: The Tagging API may not return resources that have never been tagged. Also, some costs have no tag at all (data transfer, support, taxes, some shared services) and some resource types do not support tags. Use Config for the inventory and Cost Explorer's untagged group for spend.
Interview questions
- How would you roll out mandatory tagging in an organisation of 80 accounts? Agree the standard first, report-only tag policy on a test OU, IaC default tags, a detection rule, then prevention SCPs for a few resource types, staged by OU with a break-glass exception. Measure tagged-spend percentage weekly.
- What is the difference between a tag policy and an SCP for tags? A tag policy standardises keys and values and can block non-compliant tagging operations for some resource types. An SCP can deny creating a resource when a tag is missing. Only the SCP (or other controls) can make a tag mandatory.
- Why might tag-based cost reports be wrong even with perfect tagging? Untaggable costs, shared services, activation delay and capitalisation differences. A mature FinOps practice allocates shared cost with rules (cost categories, split cost allocation) and reports the unallocated remainder openly.
- How would you find untagged resources in a multi-account organisation? Config aggregator advanced queries for the inventory, the Tagging API compliance report for tag policy compliance, Cost Explorer grouped by tag for spend.
Certification practice
A company wants every new EC2 instance in its Workloads OU to carry a CostCenter tag, and wants creation to fail if it is missing. Which solution meets this requirement?
A. An Organizations tag policy defining CostCenter with allowed values.
B. An SCP that denies ec2:RunInstances when aws:RequestTag/CostCenter is null.
C. An AWS Config rule evaluating instances once a day.
D. A budget alert on EC2 spend.
Answer: B. The SCP evaluates the request and denies creation when the tag is not supplied. A only standardises values of tags that exist and ignores untagged resources. C detects after creation and does not prevent it. D monitors cost and neither requires nor detects tags.
A bank's finance team needs per-business-line cost reports across 60 accounts. Some business lines share accounts. Which approach gives accurate showback with the least ongoing effort?
A. One account per business line only.
B. Mandatory CostCenter tags enforced through IaC and SCPs, activated as cost allocation tags in the management account, with a cost category for shared accounts.
C. Ask each team to submit spreadsheets monthly.
D. Use the AWS Pricing Calculator for each team.
Answer: B. Tags plus activation give resource-level attribution inside shared accounts, and a cost category handles grouping and shared costs. A is not possible when accounts are shared and still leaves untagged items. C is manual and error-prone. D estimates future cost, it does not report actual spend.
What must you do before a user-defined tag appears as a column in the Cost Explorer?
A. Nothing, all tags appear automatically. B. Activate it as a cost allocation tag in the Billing and Cost Management console. C. Buy a Savings Plan. D. Enable AWS Config.
Answer: B. User-defined tags must be activated as cost allocation tags. A is wrong because inactive tags do not appear. C and D are unrelated.
Completion checklist
- I can explain in two sentences why a tag policy does not make tags mandatory
- I wrote a five-tag standard with allowed values and owners
- I created and attached a tag policy to a test OU and read the effective policy
- I ran the audit tool and understand its blind spot
- I ran the cleanup steps and confirmed no lab resources remain
Key takeaways
- A small, agreed, mandatory tag set beats a long wish-list. Five tags with controlled values is enough.
- Layer the controls: tag policy (standardise), IaC (apply), Config (detect), SCP (prevent), activation (report).
- Tag policies standardise tags that exist. They do not require tags to exist.
- Cost allocation tags are activated in the management account and apply going forward.
- Tags are metadata, not secrets and not (alone) a security boundary.
Further reading
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Centralised security tooling: delegated administrators, auto-enable and a Config aggregator
Run GuardDuty, Security Hub, AWS Config and IAM Access Analyzer for the whole organisation from a dedicated security tooling account, keep the management account out of daily security work, and prove coverage with tested checks.
Compliance evidence: Config conformance packs, advanced queries and what still needs a human
Turn AWS Config into an evidence source an auditor can use: deploy a conformance pack, query resource inventory and configuration history, export a tamper-evident evidence bundle from C#, and be clear about what automation can never prove.