How can you prevent multiple copies of an entire infrastructure stack from being created when using Terraform in a CI/CD pipeline?

Study for the Google Cloud DevOps Certification Test. Prepare with interactive quizzes and detailed explanations. Enhance your skills and boost your confidence!

The correct choice is to ensure that the pipeline is storing and retrieving the terraform.tfstate file from Cloud Storage. This approach is essential because the terraform.tfstate file contains the most current state of your infrastructure. When working in a CI/CD environment, it's crucial to maintain a single source of truth regarding the configuration of your resources.

By storing the state file in a centralized location, such as Cloud Storage, multiple executions of your Terraform scripts can share and access the same state. This prevents the creation of multiple copies of the infrastructure stack, which can occur if each execution tries to create resources based on outdated or inconsistent state information. When the state file is properly managed, it ensures that any changes made to the infrastructure are applied correctly without duplicating resources.

In contrast, other options may not effectively prevent the duplication of infrastructure. For example, simply creating a new pipeline to delete old stacks does not address the root cause of managing the state file, and merely removing existing infrastructure before applying new configurations does not guarantee an accurate awareness of existing resources. Additionally, storing the state file in a source control system is not a recommended practice since it can lead to state file conflicts, especially when multiple team members or processes are accessing it concurrently. Thus, choosing to store and

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy