What should you do when changing the machine type for an instance template that leads to a Terraform pipeline failure?

Delete the managed instance group, and recreate it after updating the instance template.

Add a new instance template and update the managed instance group to use the new one.

Remove the managed instance group from the Terraform state file.

Set the create_before_destroy meta-argument to true in the lifecycle block on the instance template.

When changing the machine type for an instance template in a Terraform-managed environment, using the create_before_destroy meta-argument in the lifecycle block on the instance template ensures a smooth transition during the update process. This setting directs Terraform to create a new instance based on the revised template before it destroys the old instance.

This approach allows for seamless updates because it maintains operational continuity. Rather than waiting for the old instance to be terminated, a new instance is provisioned based on the updated configuration, making it less likely that there will be downtime or service disruptions. After the new instance is confirmed to be running successfully, Terraform will then proceed to terminate the old instance, maintaining the desired state of the infrastructure throughout the lifecycle of the deployment.

While other options might seem viable, they could lead to issues such as downtime or the need for excessive manual intervention. Deleting and recreating the managed instance group could result in service interruptions, removing the managed instance group from the Terraform state may cause inconsistencies and lead to unexpected behavior, and simply adding a new instance template without setting the appropriate lifecycle configurations could lead to a more complex and less automated infrastructure management process. Thus, setting the create_before_destroy meta-argument is the most efficient and reliable method when encountering such changes.

Want more questions?

All options are one-time payments.

$25.99

30 day pass for new members

All the basics to get you started

  • Ad-free experience
  • View your previous attempt history
  • Mobile app access
  • In-depth explanations
  • 30 day premium pass access
$59.99$171.99 usd

6 month DELUXE pass (most popular)

Full access FOR 6 MONTHS! & the ultimate digital PDF study guide (BONUS)

  • $171.99 usd value for $59.99! You save $106!
  • Ad-free experience
  • View your previous attempt history
  • Mobile app access
  • In-depth explanations
  • 6 months of full access
  • Ultimate digital PDF study guide included
  • Priority support
$15.99 $24.99

Ultimate digital PDF study guide

For those that prefer a more traditional form of learning

  • Available for instant download
  • Available offline
  • Hundreds of practice multiple choice questions
  • Comprehensive content
  • Detailed explanations
Image Description
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy