Google Professional Cloud DevOps Engineer Question 187
Select 3Google Cloud PlatformYour company is migrating its infrastructure to Google Cloud and is adopting Infrastructure as Code (IaC) to manage resources. The team has decided to use Terraform to provision and manage the infrastructure. As a DevOps engineer, you need to ensure the infrastructure is managed securely, efficiently, and follows best practices. Which of the following actions should you take to manage the infrastructure effectively in this scenario?
- A
Store the Terraform state file in a secured Google Cloud Storage bucket with versioning enabled.
- B
Hardcode sensitive variables such as API keys and service account credentials directly into Terraform configuration files for simplicity.
- C
Use Terraform modules to organize and reuse configurations across different environments.
- D
Configure access controls on the Terraform state storage to restrict unauthorized access.
- E
Manually apply changes directly to Google Cloud resources without updating Terraform configurations for faster deployments.
Show answer and explanation
Correct answers: A, C, D
Explanation
Managing infrastructure with Terraform involves following best practices to ensure security, efficiency, and maintainability. Storing the state file securely, using modules for organization, and restricting access to sensitive data are critical steps. Avoiding hardcoding sensitive variables and manual changes ensures that the infrastructure remains consistent and adheres to the principles of Infrastructure as Code.
- A. Correct.
Storing the Terraform state file in a secured Google Cloud Storage bucket with versioning enabled ensures the state file is protected, auditable, and allows for recovery in case of accidental changes.
- B. Incorrect.
Hardcoding sensitive variables in configuration files is a security risk and violates best practices. Sensitive data should be managed using tools like Terraform's sensitive variables or secrets managers.
- C. Correct.
Using Terraform modules promotes reusability, consistency, and modularity in managing infrastructure, making it easier to manage resources across environments.
- D. Correct.
Configuring access controls on the Terraform state storage ensures only authorized users and services can access or modify the state, reducing the risk of unauthorized changes.
- E. Incorrect.
Manually applying changes directly to Google Cloud resources bypasses IaC principles, leading to configuration drift and making the infrastructure harder to manage and audit.