A DevOps engineer is writing a Terraform configuration to provision an AWS EC2 instance. They want to ensure that the instance is replaced if the AMI ID changes, but not if the instance type changes. Which lifecycle meta-argument should be used?
Trap 1: Set `prevent_destroy = true`
Prevents any destruction, which is too restrictive.
Trap 2: Set `ignore_changes = all`
Ignores all changes, so AMI change wouldn't trigger replacement.
Trap 3: Set `create_before_destroy = true` only
Would still cause replacement on instance type change, not desired.
- A
Set `prevent_destroy = true`
Why wrong: Prevents any destruction, which is too restrictive.
- B
Set `ignore_changes = all`
Why wrong: Ignores all changes, so AMI change wouldn't trigger replacement.
- C
Set `create_before_destroy = true` and add `instance_type` to `ignore_changes`
Correct: creates new before destroying old, ignores instance type changes.
- D
Set `create_before_destroy = true` only
Why wrong: Would still cause replacement on instance type change, not desired.