Subdomain 1.2: Managing infrastructure.
1.Your security team requires that no Google Cloud Storage buckets are created with public access. You want to enforce this policy automatically within your Terraform CI/CD pipeline before any infrastructure is provisioned. What should you use?
- A.VPC Service Controls.
- B.Cloud Logging sinks with an alerting policy.
- C.Terraform Validator (or `gcloud beta terraform vet`) with a Policy Library.
- D.IAM Conditions restricting the creation of buckets.
Show answer & explanation
Correct answer: C — Terraform Validator (or `gcloud beta terraform vet`) with a Policy Library.
- A. Incorrect. VPC Service Controls are designed to create service perimeters to mitigate data exfiltration risks for supported Google Cloud services. They do not provide a mechanism for validating or blocking specific resource configuration attributes within a CI/CD pipeline before deployment.
- B. Incorrect. Cloud Logging sinks and alerting policies are reactive mechanisms. They notify you after a resource has been created or modified (post-provisioning). The requirement is to enforce the policy automatically within the pipeline before any infrastructure is provisioned.
- C. Correct. Terraform Validator (and its successor `gcloud beta terraform vet`) with a Policy Library enables policy-as-code checks against Terraform plan files. By integrating this into your CI/CD pipeline, you can automatically reject plans that violate security requirements—such as those creating publicly accessible GCS buckets—before resources are ever provisioned.
- D. Incorrect. IAM Conditions are used to grant permissions based on attributes like resource tags or request timing. While powerful for runtime access control, they are not intended to be used as a pre-deployment configuration validation tool in a Terraform CI/CD pipeline.