QuestionQ11

Building and implementing CI/CD pipelines, including continuous testing, for application, infrastructure, and machine learning workloads

You use Terraform to manage an application deployed in a Google Cloud environment. The application runs on instances deployed by a managed instance group. The Terraform code is deployed through a CI/CD pipeline. When you change the machine type on the instance template used by the managed instance group, the pipeline fails during the terraform apply stage with the following error message:

Question Image

You need to update the instance template while minimizing disruption to the application and the number of pipeline runs.

What should you do?

Explanation

Google Cloud does not allow deletion of an instance template while a managed instance group references it. Setting create_before_destroy = true in the instance template resource’s lifecycle block makes Terraform create the replacement template before destroying the existing one, allowing the managed instance group to switch references first and avoiding the failed deletion order.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!