What does `terraform test` do at a basic level?
BeginnerConceptLifecycle, Dependencies, Provisioners and Drift
Answer
Since 1.6 it runs .tftest.hcl files containing run blocks that apply (or plan) real configuration and assert on results, then destroys what it created.
run "bucket_is_private" {
command = plan
assert {
condition = aws_s3_bucket_public_access_block.b.block_public_acls == true
error_message = "Public ACLs must be blocked"
}
}
More on Lifecycle, Dependencies, Provisioners and Drift
What are meta-arguments?BeginnerWhat lifecycle options are available?BeginnerHow does `create_before_destroy` work and what can go wrong?AdvancedWhat does `prevent_destroy` guarantee and what does it not?AdvancedWhen do you use `ignore_changes`?IntermediateWhat does `replace_triggered_by` do?Advanced