How do you test that a module is idempotent?
IntermediateProductionTesting and Policy as Code
Answer
Apply it, then run plan and assert no changes. In terraform test, use two sequential run blocks: the second runs command = plan against the same state and asserts nothing changes; in Terratest use InitAndApplyAndIdempotent. A non-empty second plan means a perpetual diff bug.
More on Testing and Policy as Code
How do you test infrastructure code, and what does the testing pyramid look like?BeginnerWhat does the static-analysis layer catch?BeginnerWhat does tflint do, and how is it configured?BeginnerHow do Checkov and Trivy differ?IntermediateHow does `terraform test` work?BeginnerHow do mock providers work in `terraform test`?Advanced