You need to ensure that an AWS Auto Scaling Group maintains capacity during a configuration change that requires a new launch template. Which lifecycle meta-argument should you use?
Trap 1: replace_triggered_by
replace_triggered_by forces replacement of a resource when a referenced resource or attribute changes; it does not control how the ASG replaces instances during a launch template change. It is tempting because it sounds like it triggers the right replacement, but the requirement is instance refresh behaviour, handled by create_before_destroy.
Trap 2: ignore_changes
ignore_changes tells Terraform to disregard changes to specified attributes, so the launch template update would never be applied to the ASG. It is tempting because it prevents disruptive diffs, but here the change must take effect while capacity is maintained, which create_before_destroy achieves.
Trap 3: prevent_destroy
prevent_destroy blocks destruction of a resource entirely, causing an error rather than maintaining capacity during a launch template change. It is tempting because it sounds like it protects the ASG, but it stops the update instead of orchestrating a graceful replacement, which create_before_destroy provides.
- A
replace_triggered_by
Why it fails: replace_triggered_by forces replacement of a resource when a referenced resource or attribute changes; it does not control how the ASG replaces instances during a launch template change. It is tempting because it sounds like it triggers the right replacement, but the requirement is instance refresh behaviour, handled by create_before_destroy.
- B
ignore_changes
Why it fails: ignore_changes tells Terraform to disregard changes to specified attributes, so the launch template update would never be applied to the ASG. It is tempting because it prevents disruptive diffs, but here the change must take effect while capacity is maintained, which create_before_destroy achieves.
- C
create_before_destroy = true
create_before_destroy provisions the replacement launch template and instances before destroying the old ones, preventing capacity gaps during the change. This satisfies the stem's constraint that the Auto Scaling Group maintains capacity throughout the configuration change.
- D
prevent_destroy
Why it fails: prevent_destroy blocks destruction of a resource entirely, causing an error rather than maintaining capacity during a launch template change. It is tempting because it sounds like it protects the ASG, but it stops the update instead of orchestrating a graceful replacement, which create_before_destroy provides.