Courseiva
Implement and maintain stateeasyMultiple ChoiceObjective-mapped

TF-004 Implement and maintain state Practice Question

A new developer joins a project that uses Terraform with a remote backend in GCS (Google Cloud Storage). They clone the repository and run `terraform init` successfully. However, when they run `terraform plan`, they get an error: "Error loading state: AccessDenied: 403 my-project-terraform-state@my-project.iam.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage bucket." What is the most likely resolution?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Grant the `Storage Object Viewer` role to the service account on the GCS bucket

The error 'AccessDenied: 403 ... does not have storage.objects.get access' indicates that the service account used by Terraform lacks read permissions on the GCS bucket. Granting the 'Storage Object Viewer' role to that service account on the bucket provides the necessary `storage.objects.get` permission, allowing Terraform to read the state file. Option C is correct; options A, B, and D are not appropriate solutions.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Disable access control on the bucket temporarily

    Why it's wrong here

    Disabling access control on the GCS bucket, such as making it publicly accessible or removing all IAM policies, is a severe security vulnerability. The Terraform state file often contains sensitive information, including resource IDs, configurations, and potentially secrets, which would then be exposed to unauthorized entities. This approach does not solve the underlying problem of a specific service account lacking the necessary permissions; instead, it creates a much larger security incident by compromising the integrity and confidentiality of the infrastructure state.

  • Run `terraform init -reconfigure` to regenerate the backend configuration

    Why it's wrong here

    Running `terraform init -reconfigure` is used to re-initialize the backend configuration, re-download providers, and update modules, but it does not modify or grant any Identity and Access Management (IAM) permissions on cloud resources. This command operates on the local Terraform working directory and interacts with the configured backend to establish connectivity. It cannot alter the server-side access policies that govern which service accounts or users can interact with the GCS bucket where the state file is stored. Therefore, it will not resolve a permissions error.

  • Grant the `Storage Object Viewer` role to the service account on the GCS bucket

    Why this is correct

    Granting the `Storage Object Viewer` role to the service account directly addresses the issue of insufficient permissions for reading the Terraform state file stored in Google Cloud Storage. This specific IAM role provides the necessary `storage.objects.get` permission, allowing the service account to retrieve the state file's contents. Terraform requires read access to the state file to understand the current infrastructure's deployed configuration before planning any changes, ensuring consistency and preventing unintended modifications. This is a secure and precise way to resolve the access problem.

  • Change the backend to local state and commit the state to the repository

    Why it's wrong here

    Changing the backend to local state and committing it to a repository fundamentally undermines the benefits of using remote state for collaborative Terraform development. Local state files are prone to being out of sync among team members, leading to inconsistent infrastructure views and potential state corruption. Furthermore, committing the state file, which can contain sensitive data, directly into version control is a significant security risk and makes version control cumbersome due to large, frequently changing binary files and merge conflicts. It defeats the purpose of a shared, consistent, and secure state.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.