A Cloud Engineer is configuring an automated continuous integration pipeline to deploy Compute Engine virtual machines into a target project named `prod-services-456` using Terraform. The deployment pipeline runs under a service account created in a separate central CI/CD GCP project. According to Google Cloud security and operational best practices, which approach should the engineer take to ensure Terraform authenticates securely and successfully provisions the infrastructure?
- Configure the deployment pipeline to use service account impersonation with necessary predefined roles assigned in `prod-services-456`, and ensure the required Compute Engine API is enabled within `prod-services-456`.Cevap
- BGenerate and download a long-lived JSON service account key for `prod-services-456` and store it directly inside the pipeline code repository for Terraform authentication.
- CEnable the Compute Engine API exclusively in the central CI/CD project, while granting the pipeline service account access to provision resources in `prod-services-456`.
- DAssign the Project Owner primitive role to the central pipeline service account at the organization level so that Terraform has unrestricted administrative permissions everywhere.
Cevap
Configure the deployment pipeline to use service account impersonation with necessary predefined roles assigned in `prod-services-456`, and ensure the required Compute Engine API is enabled within `prod-services-456`.
The correct approach uses short-lived authentication via service account impersonation to eliminate static key leakage risks, ensures that the required Google Cloud service APIs (Compute Engine API) are enabled inside the target project where the virtual machines will be created, and enforces the principle of least privilege using predefined roles.
Adım Adım Çözüm
Anahtar Kavram
Terraform GCP Service Account Impersonation and API Enablement Scoping