AWS Tag Compliance Audit
Check all AWS resources for required tags (owner, environment, cost-center) and generate remediation scripts.
Tested against aws-cli 2.x · claude-code-1.8+ · cursor-0.45+
You are an AWS governance engineer. Your task is to audit resources for required tags and generate idempotent remediation scripts. Context: - Tagging is mandatory for owner, environment, and cost-center on all resources. - You have read access to list resources and their tags; you will generate scripts, not run them against prod. - Assume the agreed required tags are owner, environment, cost-center. Steps: 1. Enumerate representative resources and their tags: use aws resourcegroupstaggingapi get-resources with no filter to pull all tagged and untagged resources (it returns untagged too). 2. For each resource, check that owner, environment, and cost-center are present and non-empty. 3. Summarize compliance by resource type, counting resources missing at least one required tag. 4. For non-compliant resources, propose the standard values (for example, environment = dev|staging|prod, cost-center = a known code) and generate a remediation command for the common cases. 5. Generate an idempotent script that applies the default tags only to resources whose required tags are missing, so rerunning does not overwrite correct values. Output format: - Compliance summary table (resource type, total, compliant, missing tags). - A ready-to-run bash or Python remediation snippet that tags only the gaps. Constraints: - Never run the remediation against production resources; output it for review. - Do not overwrite existing valid required tags; only add missing ones. - Flag synthetic resources (like log groups) that may have no owner by design. Example: Input: three EC2 instances have no cost-center tag; two have no owner. Output: compliance table shows EC2 10 total, 5 compliant, 5 missing cost-center; remediation script adds cost-center=payments only where the tag is absent.
Why this directive matters
Tagging is the quiet backbone of cloud cost and ownership. Without an owner tag, no billing report can say who to charge, and without an environment tag, automation cannot tell production from sandbox. The problem is enforcement, because tags added late are rarely applied back to existing resources. This directive turns the agent into a tagging enforcer that works the safe way: it lists resources and their tags, computes a per-resource-type compliance count against a small agreed set of required tags, and then generates an idempotent remediation script that only fills in missing tags. Not overwriting valid values is the whole trick, and the script being idempotent means it can run on a schedule without creating drift of its own. The output gives a governance team a number to put on a dashboard and a patch they can review before it touches anything.
Test Command
aws resourcegroupstaggingapi get-resources --output jsonPrerequisites
- aws resourcegroupstaggingapi:GetResources
- Read-only listing permissions
- Agreed required tags list
Expected Outputs
- Compliance summary by resource type
- Idempotent remediation script
- Gap counts
References
- Kubernetes Documentation | Concepts: authoritative concepts for cluster, RBAC, and workload audits.
- Terraform Documentation: plan, state, and provider reference for IaC directives.
- AWS Documentation: IAM, Cost Explorer, and service reference for cloud directives.
- CNCF Landscape: cloud-native tooling context for multi-cloud directives.
Automate it past the prompt.
This beginner directive is a manual, read-only run. Devopsify can run the same check continuously across your estate, with policy gates, approvals, and a retained audit trail.