Google Professional Cloud DevOps Engineer Question 68
Select 3Google Cloud PlatformYou are tasked with implementing a CI/CD pipeline for managing infrastructure in your Google Cloud environment. Your team uses Terraform for infrastructure as code (IaC) to provision GKE clusters, managed instance groups, and a Cloud Service Mesh configuration. Which steps should you include in your CI/CD pipeline to ensure a reliable and automated infrastructure deployment process?
- A
Run Terraform plan in the CI pipeline to validate the changes before applying them.
- B
Store Terraform state files in a version-controlled Git repository.
- C
Implement automated tests in the pipeline to validate the functionality of the infrastructure after deployment.
- D
Use a Google Cloud Build trigger to automatically apply Terraform changes to the production environment on every commit to the repository.
- E
Enable Terraform state locking by using a remote backend such as Google Cloud Storage with a bucket lock.
Show answer and explanation
Correct answers: A, C, E
Explanation
To ensure a reliable and automated infrastructure deployment process using CI/CD, it is crucial to validate changes (e.g., using 'Terraform plan'), implement automated tests to confirm functionality, and enable state locking to prevent corruption. Storing state files in a secure remote backend like Google Cloud Storage is a best practice, while directly applying changes to production on every commit can introduce risks and is not recommended.
- A. Correct.
Running 'Terraform plan' in the CI pipeline is a best practice for validating changes before they are applied. It ensures that unintended changes do not get deployed.
- B. Incorrect.
Storing Terraform state files in a Git repository is not recommended because it can lead to conflicts, security risks, and a lack of state locking. Instead, a remote backend should be used.
- C. Correct.
Automated tests validate the functionality of infrastructure after deployment, ensuring that the infrastructure behaves as expected and reducing risks of misconfiguration.
- D. Incorrect.
Automatically applying Terraform changes to production on every commit is risky and not aligned with best practices. Manual approvals or additional checks are typically required for production changes.
- E. Correct.
Enabling Terraform state locking with a remote backend like Google Cloud Storage ensures consistency and prevents multiple concurrent operations from corrupting the state.