A cloud engineering team is constructing an automated CI/CD deployment pipeline to provision infrastructure in a new Google Cloud project named `prod-workloads-456` using Terraform. The pipeline executes using a dedicated deployment service account residing in a central management project `ci-cd-tools-100`. During the initial run of `terraform apply` targeting `prod-workloads-456`, the deployment fails with an error indicating that `compute.googleapis.com` is not enabled. Furthermore, corporate security policy strictly prohibits storing long-lived credentials in pipeline secrets. Which set of actions adheres to Google Cloud best practices to resolve the deployment failure and secure pipeline authentication?
- Enable the Compute Engine API directly within the target project `prod-workloads-456`, and configure the CI/CD pipeline to authenticate using short-lived credentials via IAM Service Account Impersonation.Cevap
- BEnable the Compute Engine API in the central management project `ci-cd-tools-100` where the Terraform CLI executes, and export a long-lived service account JSON key for pipeline authentication.
- CGenerate a downloadable service account JSON key, store it in the repository secret manager, and grant the service account `roles/owner` at the organization level to automatically bypass project-level API requirements.
- DGrant `roles/resourcemanager.organizationAdmin` to the pipeline service account at the parent folder level so that API enablement settings are inherited down the resource hierarchy without modifying the target project.
Cevap
Enable the Compute Engine API directly within the target project `prod-workloads-456`, and configure the CI/CD pipeline to authenticate using short-lived credentials via IAM Service Account Impersonation.
The correct approach requires enabling the required Cloud API (`compute.googleapis.com`) directly on the target project (`prod-workloads-456`) where resources will reside. For pipeline security, Google Cloud recommends using short-lived credentials generated via IAM Service Account Impersonation or Workload Identity Federation instead of downloading persistent JSON keys.
Adım Adım Çözüm
Anahtar Kavram
GCP IaC Security Best Practices and Service API Scoping