You want to give a Terraform service account permission to create, update, and delete Compute Engine instances only. Which IAM role grants the least privilege for this task?
Look for the role that limits permissions to managing instances only, not the entire project.
roles/compute.instanceAdmin.v1 allows managing Compute Engine instances without broader project permissions. Other roles like compute.admin or owner have more permissions than needed.
Which practice is best to securely manage Terraform service account keys?
Think about minimizing risk if keys are exposed.
Short-lived credentials and regular rotation reduce risk. Storing keys in a secure secrets manager prevents accidental exposure. Avoid sharing keys openly or using default accounts with broad permissions.
You want a Terraform service account to only read and write objects in a specific Cloud Storage bucket. Which IAM binding configuration grants the least privilege?
resource "google_storage_bucket_iam_member" "terraform_sa_access" { bucket = "my-terraform-bucket" role = role member = "serviceAccount:terraform-sa@example.iam.gserviceaccount.com" }
Consider which role allows both reading and writing objects but not managing the bucket itself.
roles/storage.objectAdmin allows read and write access to objects in the bucket without permissions to manage bucket settings. Other roles either allow only read, only write, or full bucket management.
You manage multiple GCP projects and want Terraform service accounts to have least privilege access only to their assigned projects. What architecture best supports this?
Think about isolating permissions per project to reduce risk.
Separate service accounts per project with scoped roles limit blast radius if credentials are compromised. Using one account with broad roles increases risk. User credentials are not recommended for automation.
Terraform runs a plan and apply to create a Compute Engine instance, but the service account lacks the required IAM permission. What is the expected behavior?
Consider how Terraform handles errors during resource creation.
Terraform stops and reports an error if the service account lacks permissions to create a resource. It does not partially apply or silently ignore permission issues.