A module used by four environments and verified by applying it and looking at the console.
run "tags_are_applied_to_everything" {
command = plan
variables { name = "app", environment = "test" }
assert {
condition = alltrue([
for r in [aws_s3_bucket.this, aws_sqs_queue.this] :
lookup(r.tags_all, "Environment", "") == "test"
])
error_message = "a resource is missing the Environment tag"
}
}
The tagging assertion is the one that earns its place immediately, because a missing tag is invisible in a plan review and expensive in a cost report. Writing tests against a plan rather than an apply keeps them fast enough to run on every change, and the first run found two resources that had never had tags at all.