Cost allocation tags: a tagging policy that survives contact with engineers

AWS tag policies don’t count untagged resources as noncompliant: “Untagged resources don’t show as noncompliant in compliance results,” per the AWS Organizations tag policy best practices. So your compliance report can look clean while part of your bill has no owner, and the first number to measure is untagged spend in the bill itself.

Cost allocation tags also don’t count until you activate them: “For tags to appear on your billing reports, you must activate them,” says the AWS Billing documentation. The order that works is measure untagged spend, activate keys, report, fix, and enforce last, only on resource types AWS can enforce.

Why do my tags show as compliant even when resources have none?

AWS tag policies check the tags a resource already has: allowed values and key capitalization. They don’t flag a resource with no tags. AWS says so twice: “Untagged resources don’t show as noncompliant in compliance results,” and tag policy enforcement does “not enforce tag compliance on resources that are created without tags.”

That means a clean compliance report and untagged EC2 instances, Lambda functions or RDS clusters can exist side by side. To require tags at creation, AWS points to service control policies (SCPs). For EC2, deny ec2:RunInstances on the instance resource when the request carries no CostCenter tag:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyRunInstancesWithoutCostCenter",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": "arn:aws:ec2:*:*:instance/*",
      "Condition": { "Null": { "aws:RequestTag/CostCenter": "true" } }
    }
  ]
}

Keep the instance/* scope. Without it, the condition also matches the subnet, security group and AMI in the same call, and the SCP blocks every launch. SCPs don't apply to the management account, so attach and test this one on a test member account first: it also blocks any tool that creates a resource and tags it afterward.

How do I find untagged spend in my bill?

For one key that's already activated as a cost allocation tag, open Cost Explorer, group by Tag, pick the key, and read the row for resources without it. For the whole bill, query your CUR 2.0 export in Amazon Athena. CUR 2.0’s resource_tags column only holds keys enabled as cost allocation tags, so activate your keys first or tagged resources will look untagged. User-defined keys appear in the map with a user_ prefix. In Athena, run this:

SELECT
  line_item_usage_account_id,
  SUM(line_item_unblended_cost) AS untagged_cost
FROM cur2_table  -- your CUR 2.0 table
WHERE billing_period = 'YYYY-MM'  -- the month you want
  AND line_item_line_item_type = 'Usage'
  AND (resource_tags IS NULL
       OR cardinality(map_filter(resource_tags, (k, v) -> k LIKE 'user_%' AND v <> '')) = 0)
GROUP BY line_item_usage_account_id
ORDER BY untagged_cost DESC;

In Azure, open Cost Management → Cost analysis, group by Tag, pick your key, and read the untagged row. Azure tags only show in usage data while they’re applied; they “aren’t applied to historical data,” so spend from before you tagged a resource stays untagged. In Google Cloud, labels are exported to BigQuery with usage, so query your billing export:

SELECT
  project.id AS project_id,
  SUM(cost) AS unlabeled_cost
FROM `your-project.your_dataset.gcp_billing_export_v1_*`
WHERE invoice.month = 'YYYYMM'  -- the month you want
  AND ARRAY_LENGTH(labels) = 0
GROUP BY project_id
ORDER BY unlabeled_cost DESC;

/checker reports the share of your usage spend that carries no user: cost allocation tag and flags it above 10%. That 10% is our own cutoff, not an industry figure. Whatever your number is, it’s the baseline every later step gets measured against.

Check your own bill in 2 minutes: https://revelations.consulting/checker?utm_source=blog&utm_medium=organic&utm_content=blog-cost-allocation-tags-policy

How do I fix untagged spend without breaking deployments?

Start with activation. “For tags to appear on your billing reports, you must activate them.” A new key can take up to 24 hours to show up on the Cost allocation tags page in the Billing and Cost Management console, then up to 24 hours more to activate. Until then, CUR 2.0’s resource_tags column doesn’t hold it.

From the management account, you can activate by CLI, up to 20 keys per call:

aws ce update-cost-allocation-tags-status \
  --cost-allocation-tags-status TagKey=CostCenter,Status=Active TagKey=Owner,Status=Active
aws ce list-cost-allocation-tags --status Active

The management account can backfill cost allocation tags for up to twelve months, once every 24 hours. Values appear only for months the resource actually carried the tag, so backfill doesn’t rescue spend that was untagged.

Azure has no activation step, but its tags “aren’t applied to historical data.” And “Resources don’t inherit the tags you apply to a resource group or a subscription,” so tagging the resource group alone leaves its resources untagged in your cost data.

Next, pick your required keys. Keep the list short: a few keys every team can fill in correctly, such as CostCenter, Owner and Environment. Pick one capitalization per key and never vary it. You’re not building a data warehouse. You’re assigning accountability.

Then write your first tag policy and attach it to a test member account, not your production OU. Start simple: one key, one capitalization (CostCenter), report-only. report_required_tag_for is the report-only form; it blocks nothing:

{
  "tags": {
    "costcenter": {
      "tag_key": { "@@assign": "CostCenter" },
      "report_required_tag_for": { "@@assign": ["ec2:instance"] }
    }
  }
}
aws organizations enable-policy-type --root-id <root-id> --policy-type TAG_POLICY
aws organizations create-policy --type TAG_POLICY --name costcenter-report \
  --description "Report-only CostCenter" --content file://costcenter-report.json
aws organizations attach-policy --policy-id <policy-id> --target-id <test-account-id>

Let it run through your normal deploys, then fix what the compliance report and your untagged-spend query show. Only then add enforced_for, and only for resource types AWS lists as supported for enforcement.

Test enforcement on a test account first. AWS warns that enforcement can stop users creating resources they need, and that it “may block dynamic scaling and provisioning” where tags propagate. A scale-out that fails on a tag value fails when you need capacity most. Enforce one resource type at a time, watch deployments and scaling events, and keep the report-only policy attached so you can detach the enforcing one fast.

Keep all tag keys in your infrastructure-as-code. Never add them manually. If your Terraform module doesn’t require Owner, fix the module, not the resource.

Design your keys around these limits:

CloudLimit to design around
AWSServices generally allow 50 user-defined tags per resource; keep required tags under 50 per resource type. Tag policies are at most 10,000 characters each (the console strips extra whitespace, the CLI does not), with 10 attached directly per root, OU or account.
AzureAt most 50 tag name-value pairs per resource, resource group or subscription. Names up to 512 characters, values up to 256. Names are case-insensitive, values case-sensitive.
Google CloudUp to 64 labels per resource. Keys and values up to 63 characters: lowercase letters, numbers, underscores and dashes, and keys start with a lowercase letter. Labels are exported to BigQuery with usage.

Google Cloud labels must be lowercase, so map CostCenter to one lowercase key such as cost_center there. In Azure, Prod and prod are different values, so fix allowed values in Azure Policy, not by convention.

What it usually looks like

Untagged spend usually sits where resources get created outside the code path that sets tags. Check these in your own account: resources launched from the console or CLI, resources created by CI/CD pipelines or third-party tools that don't pass your tags, and leftovers such as EBS volumes and snapshots whose instance is gone.

In Azure, look for resource groups that carry your tags while the resources inside them don't, because resources don't inherit resource group tags. In Google Cloud, add service.description to the unlabeled-cost query above to see which services carry the gap.

You won’t find these in your AWS tag policy compliance results. You’ll find them when you query your bill: add line_item_product_code to the CUR 2.0 Athena query above to see which AWS services carry the untagged spend.

If you want a second pair of eyes on your untagged spend before you enforce anything, book a free 30-minute consult: we’ll look at your bill with you, no obligation and no sales pitch.

The rollout order is simple: measure untagged spend, activate keys, report, fix, enforce last.

Run your own numbers: tag policy generator

Frequently asked questions

How long does it take for cost allocation tags to appear in AWS billing reports?

AWS cost allocation tag keys can take up to 24 hours to appear on the Cost allocation tags page for activation, then up to 24 hours to activate. Only activated keys show up in billing reports and in CUR 2.0’s resource_tags column.

Can I backfill tags for past months in AWS?

Yes, but only for months when the resource already carried the tag. The AWS management account can backfill cost allocation tags for up to twelve months, once every 24 hours. If a resource was untagged in a given month, a backfill won’t assign that month’s cost to any tag value.

Do Azure resource groups inherit tags to their resources?

No. “Resources don’t inherit the tags you apply to a resource group or a subscription” in Azure. To copy a resource group tag onto its resources, assign an Azure Policy with the Modify effect, such as the built-in “Inherit a tag from the resource group” policy, and run a remediation task for existing resources.

Can I enforce tags on all AWS resource types?

No. AWS tag policy enforcement (enforced_for) works only on the resource types AWS lists as supported for enforcement in the AWS Organizations documentation, so check that list before you add a type. Enforcement also doesn’t stop resources being created without tags; to require tags at creation, AWS points to service control policies (SCPs).

What happens if I enforce a tag policy and break deployments?

When AWS tag policy enforcement breaks deployments, the failed calls show up as errors in CloudTrail, CloudFormation stack events and your CI/CD logs. Detach the enforcing policy with aws organizations detach-policy --policy-id <policy-id> --target-id <target-id>, keep the report-only version attached, then fix the tag in your IaC or remove that resource type from enforced_for before you enforce again.

Run the numbers on your own bill: Cost allocation tag policy generator. Free, in your browser.

Want this kind of thing weekly? Get Cloud Bill Weekly. Want us to find it in your bill? We're taking three founding clients for a free Cost Assessment.