nerdexam
Google

PROFESSIONAL-CLOUD-DEVOPS-ENGINEER · Question #85

Your company uses Jenkins running on Google Cloud VM instances for CI/CD. You need to extend the functionality to use infrastructure as code automation by using Terraform. You must ensure that the…

The correct answer is C. Create a dedicated service account for the Terraform instance. Download and copy the secret. To authorize a Jenkins instance on a Google Cloud VM to create resources with Terraform, create a dedicated service account with specific permissions, and use its key file for authentication.

Submitted by omar99· Apr 18, 2026Building and implementing CI/CD pipelines for a service

Question

Your company uses Jenkins running on Google Cloud VM instances for CI/CD. You need to extend the functionality to use infrastructure as code automation by using Terraform. You must ensure that the Terraform Jenkins instance is authorized to create Google Cloud resources. You want to follow Google-recommended practices. What should you do?

Options

  • AConfirm that the Jenkins VM instance has an attached service account with the appropriate
  • BUse the Terraform module so that Secret Manager can retrieve credentials.
  • CCreate a dedicated service account for the Terraform instance. Download and copy the secret
  • DAdd the gcloud auth application-default login command as a step in Jenkins before running the

How the community answered

(19 responses)
  • A
    5% (1)
  • B
    16% (3)
  • C
    74% (14)
  • D
    5% (1)

Why each option

To authorize a Jenkins instance on a Google Cloud VM to create resources with Terraform, create a dedicated service account with specific permissions, and use its key file for authentication.

AConfirm that the Jenkins VM instance has an attached service account with the appropriate

Relying solely on the Jenkins VM's attached service account might mean the VM has broader permissions than required by Terraform, or insufficient permissions, failing to adhere to least privilege.

BUse the Terraform module so that Secret Manager can retrieve credentials.

Using a Terraform module for Secret Manager to retrieve credentials is a good practice for storing credentials, but the question is about authorizing the Jenkins instance to *use* credentials to create resources, which requires the initial credential setup, not just retrieval.

CCreate a dedicated service account for the Terraform instance. Download and copy the secretCorrect

Creating a dedicated service account for the Terraform instance and downloading its key file allows for granular permissions tailored to Terraform's needs, strictly adhering to the principle of least privilege. While managing key files requires careful handling (e.g., using Secret Manager), this is a common and recommended practice for external systems like Jenkins needing to authenticate as a service account outside of a VM's default service account, ensuring explicit control over the Terraform's identity and permissions.

DAdd the gcloud auth application-default login command as a step in Jenkins before running the

The `gcloud auth application-default login` command is typically for user authentication, not suitable for automated service account authentication in CI/CD pipelines, and does not follow Google's recommended practices for service accounts.

Concept tested: Service account authentication for CI/CD

Source: https://cloud.google.com/iam/docs/creating-managing-service-accounts#using_service_account_keys

Topics

#CI/CD#Terraform#IAM#Service Accounts

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVOPS-ENGINEER Practice