Courseiva
Read, generate and modify configurationeasyMultiple ChoiceObjective-mapped

TF-004 Read, generate and modify configuration Practice Question

Exhibit

Refer to the exhibit.

```hcl
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  tags = {
    Name = "WebServer"
  }
}
```

Refer to the exhibit. A developer runs 'terraform plan' and receives the following error: 'Error: InvalidAMIID.NotFound: The image id '[ami-0c55b159cbfafe1f0]' does not exist'. What is the most likely cause?

⚠ Common exam trap

HashiCorp often tests the misconception that AMI IDs are globally unique across all AWS regions, when in fact they are region-specific, leading candidates to overlook the provider region configuration.

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 AMI is not available in the region specified in the provider configuration.

The error 'InvalidAMIID.NotFound' indicates that the specified AMI ID does not exist in the AWS region configured in the Terraform provider block. AMI IDs are region-specific; an AMI available in us-east-1 may not exist in eu-west-2. Terraform validates the AMI against the region's EC2 API, and if the ID is not found, it throws this exact error.

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 'tags' block is missing a required 'ami' tag.

    Why it's wrong here

    The 'tags' block in an AWS resource definition is used for applying metadata, such as 'Name' or 'Environment', to the created resource. These tags are entirely optional unless an organization's AWS Tag Policy explicitly enforces their presence. A missing or incorrect tag will not prevent an Amazon Machine Image (AMI) from being found or an instance from being provisioned if the AMI itself is valid and available. The error described would indicate an issue with the AMI's existence, not its associated metadata.

  • The AMI is not available in the region specified in the provider configuration.

    Why this is correct

    Amazon Machine Images (AMIs) are inherently regional resources within AWS. An AMI ID, such as 'ami-0abcdef1234567890', uniquely identifies an image within a specific AWS region. If a Terraform configuration's AWS provider is set to 'us-east-1', but the specified AMI ID only exists in 'us-west-2', Terraform will fail during the plan phase, reporting that the AMI cannot be found in the 'us-east-1' region. This is a common cause of "AMI not found" errors, even if the AMI exists elsewhere.

  • The 'ami' argument is misspelled; it should be 'image_id'.

    Why it's wrong here

    For the 'aws_instance' resource in the Terraform AWS provider, the correct argument name to specify the Amazon Machine Image ID is indeed 'ami'. While other AWS resources or services might use 'image_id' (e.g., 'aws_launch_template' or 'aws_ecs_task_definition'), 'ami' is the established and expected argument for directly launching an EC2 instance. Therefore, suggesting 'image_id' as the correct name instead of 'ami' for an 'aws_instance' resource is incorrect.

  • The AMI ID is malformed; it should start with 'ami-' but the rest is incorrect.

    Why it's wrong here

    AWS AMI IDs adhere to a specific format, always starting with 'ami-' followed by 17 hexadecimal characters (e.g., 'ami-0abcdef1234567890'). The question implies the AMI ID provided in the configuration *appears* to follow this correct format. If the ID were truly malformed (e.g., missing characters, incorrect prefix), AWS would typically return a "malformed ID" or "invalid parameter value" error, rather than an error indicating the AMI simply "does not exist." The error suggests the format is valid, but the specific AMI ID is not registered in the target region.

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.