Courseiva
Deployment →easyMultiple Choice

CV0-004 Deployment Practice Question

A cloud engineer is writing a Terraform configuration to provision an AWS EC2 instance. They need to pass the AMI ID as a variable to make the configuration reusable. Which Terraform block should be used to define the variable?

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

✓

variable

Variables are defined using the 'variable' block. 'resource' declares resources; 'provider' configures providers; 'output' defines outputs.

Answer analysis

Option-by-option breakdown

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

  • ✗

    output

    Why it's wrong here

    An output block exports values from a Terraform configuration after apply, such as the instance ID; it cannot declare an input variable. It is tempting because outputs do reference values, but declaring reusable inputs requires a variable block, which is what the AMI ID parameter needs.

  • ✗

    provider

    Why it's wrong here

    A provider block configures the plugin and credentials for a target platform such as AWS; it does not declare input variables. It is tempting because the EC2 resource sits inside AWS, but the AMI ID must be declared in a variable block to be passed in.

  • ✓

    variable

    Why this is correct

    The variable block declares an input variable, letting the AMI ID be supplied at plan or apply time rather than hard-coded, which makes the configuration reusable across environments. Output exposes values, locals compute intermediates, and provider configures the AWS plugin.

  • ✗

    resource

    Why it's wrong here

    A resource block declares the EC2 instance itself, so placing the AMI ID there hard-codes it rather than exposing it for reuse. Variable blocks exist precisely to parameterise values like AMI IDs; resource blocks are for provisioning infrastructure, which is why this option misplaces the declaration.

About these practice questions

One of 834 original CV0-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 CV0-004 practice question is part of Courseiva's free CompTIA 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 CV0-004 exam.