Courseiva
Use the core Terraform workfloweasyMultiple ChoiceObjective-mapped

TF-004 Use the core Terraform workflow Practice Question

Exhibit

Refer to the exhibit.

```hcl
# main.tf
terraform {
  backend "s3" {
    bucket = "my-org-terraform-state"
    key    = "prod/terraform.tfstate"
    region = "us-east-1"
  }
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}
```

Refer to the exhibit. A developer runs `terraform init` and then `terraform plan`. The plan output shows that Terraform will create the AWS instance. However, the state file is expected to be stored in S3 under the key "prod/terraform.tfstate". Which statement is true?

⚠ Common exam trap

HashiCorp often tests the misconception that the provider region automatically applies to the backend, leading candidates to incorrectly assume the backend uses the provider's region instead of the default us-east-1.

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

The state will be stored in S3 in the us-east-1 region, and the EC2 instance will be created in us-west-2

The backend configuration specifies the S3 bucket and key 'prod/terraform.tfstate' for state storage, and the AWS provider region (us-west-2) is independent of the backend region. The backend block does not include a 'region' argument, so Terraform defaults to us-east-1 for state storage, while the EC2 instance is created in the provider's configured region (us-west-2).

Answer analysis

Option-by-option breakdown

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

  • The state will be stored locally because the S3 backend configuration is invalid

    Why it's wrong here

    The S3 backend configuration, as typically defined with `backend "s3" { ... }` blocks, is syntactically valid and not inherently invalid. Terraform `init` would attempt to configure this remote backend as specified. If the designated S3 bucket does not exist, `terraform init` would fail with a clear error message indicating the inability to access or create the bucket, rather than silently defaulting to local state storage. Local state is only utilized when no remote backend is configured at all or if the configuration is truly malformed.

  • The state will be stored in S3 in the us-west-2 region because the provider overrides the backend region

    Why it's wrong here

    The region specified within the `backend "s3"` block (e.g., `region = "us-east-1"`) dictates where the Terraform state file will be stored in S3. This is entirely separate from the region configured within the `provider "aws"` block (e.g., `region = "us-west-2"`), which governs where resources like EC2 instances are provisioned. The provider's region setting does not override or influence the backend's region setting; they serve distinct and independent purposes.

  • The state will be stored in S3 in the us-east-1 region, and the EC2 instance will be created in us-west-2

    Why this is correct

    The `backend "s3"` configuration explicitly defines `region = "us-east-1"`, which means Terraform will store its state file in an S3 bucket located within the `us-east-1` AWS region. Concurrently, the `provider "aws"` block specifies `region = "us-west-2"`, directing all AWS resources managed by this provider, such as the EC2 instance, to be provisioned within the `us-west-2` AWS region. These two region settings operate entirely independently, serving distinct purposes within the Terraform workflow.

  • The `terraform plan` will fail because the S3 bucket is not created yet

    Why it's wrong here

    If the S3 bucket specified in the backend configuration does not exist, the `terraform init` command would fail during its initialization phase. `terraform init` is responsible for configuring the backend, downloading providers, and setting up modules, and a successful backend configuration is a prerequisite for subsequent commands. A successful `init` is required for `terraform plan` to execute, as `plan` relies on a properly configured backend to read the current state. Therefore, `plan` would not even be reached if `init` failed due to a missing bucket.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.