WebMagicInformatica
Terraform Associate (004) practice questions

Terraform Associate (004) practice questions: Infrastructure as Code (IaC) with Terraform

5 free questions on Infrastructure as Code (IaC) with Terraform, 8% of the HashiCorp Terraform Associate exam. Try each one, then open the answer and explanation. None of them are in the free readiness check, so you can still take it fresh.

Question 1

A team provisions environments by clicking through a cloud console. Environments drift apart and nobody can explain why staging differs from production. Which benefit of Infrastructure as Code most directly addresses this problem?

  1. A.

    The environment is defined in version-controlled code, so it can be reviewed and reproduced consistently.

  2. B.

    IaC removes the need for any testing of infrastructure changes.

  3. C.

    IaC guarantees that nobody can ever change resources outside the code.

  4. D.

    IaC makes cloud providers charge less for resources.

Show answer and explanation

Answer: A

With IaC, the desired infrastructure lives in code that is versioned and reviewed, so each environment is created the same way and changes are traceable.

  • IaC removes the need for any testing of infrastructure changes.: Changes still need review and testing; IaC makes that practical.
  • IaC guarantees that nobody can ever change resources outside the code.: Manual changes remain possible; IaC helps you detect and correct them.
  • IaC makes cloud providers charge less for resources.: IaC does not change provider pricing.
Question 2

How can a single Terraform workflow manage resources in AWS, Azure and a DNS provider?

  1. A.

    Terraform contains built-in code for every cloud API in its core binary.

  2. B.

    You must write a separate Terraform installation for each platform.

  3. C.

    Terraform converts HCL into shell scripts that call each vendor's CLI.

  4. D.

    Each platform is accessed through a provider plugin that translates Terraform resources into that platform's API calls.

Show answer and explanation

Answer: D

Providers are plugins that expose a platform's resource types and handle its API. One configuration can use many providers.

  • Terraform contains built-in code for every cloud API in its core binary.: Platform support lives in separately distributed provider plugins.
  • You must write a separate Terraform installation for each platform.: One installation can use multiple providers.
  • Terraform converts HCL into shell scripts that call each vendor's CLI.: Providers call the APIs directly, not vendor CLIs.
Question 3

Which task is Terraform primarily designed for, compared with configuration-management tools such as Ansible?

  1. A.

    Installing and configuring software packages inside running servers.

  2. B.

    Running application unit tests on every commit.

  3. C.

    Provisioning and managing the lifecycle of infrastructure resources such as networks, VMs and databases.

  4. D.

    Monitoring application performance in production.

Show answer and explanation

Answer: C

Terraform is a provisioning tool for creating, updating and destroying infrastructure. Configuration-management tools mostly configure software inside existing servers.

  • Installing and configuring software packages inside running servers.: That is typical of configuration-management tools.
  • Running application unit tests on every commit.: That is a CI task.
  • Monitoring application performance in production.: That is observability tooling.
Question 4

What is configuration drift?

  1. A.

    A Terraform CLI version that is older than the provider.

  2. B.

    A difference between the real infrastructure and what the configuration and state describe, usually caused by changes made outside of Terraform.

  3. C.

    A module that uses too many variables.

  4. D.

    A variable that has no default value.

Show answer and explanation

Answer: B

Drift appears when resources are changed manually or by other tools. A plan reveals it and an apply can bring the real objects back to the configuration.

  • A Terraform CLI version that is older than the provider.: Version mismatch is not drift.
  • A module that uses too many variables.: Module design is unrelated.
  • A variable that has no default value.: A missing default does not describe infrastructure drift.
Question 5

When a new microservice is onboarded, a platform team must create an Azure resource group, a GitHub repository, a Datadog monitor and a PagerDuty escalation policy. The team wants one reviewed change and one workflow for all of it. Which statement about Terraform is correct?

  1. A.

    Terraform can manage only virtual machines and networks, so the SaaS items need separate scripts.

  2. B.

    Terraform can manage the SaaS items only through local-exec provisioners that call each vendor's CLI.

  3. C.

    Terraform can manage any platform that has a provider, including SaaS services, so all four can be in one configuration and one plan.

  4. D.

    Terraform needs one installation per vendor, and each installation must be run separately.

Show answer and explanation

Answer: C

Terraform's workflow is service-agnostic: anything with an API and a provider (cloud platforms, SaaS tools such as GitHub, Datadog and PagerDuty, Kubernetes and more) can be declared in the same configuration, previewed in one plan and applied together.

  • Terraform can manage only virtual machines and networks, so the SaaS items need separate scripts.: Providers exist for many SaaS and platform services, not just infrastructure-as-a-service.
  • Terraform can manage the SaaS items only through local-exec provisioners that call each vendor's CLI.: Provisioners are a last resort; providers model these objects as real resources in plan and state.
  • Terraform needs one installation per vendor, and each installation must be run separately.: One Terraform CLI uses many provider plugins in a single run.

How ready are you for Terraform Associate (004)?

Take the free readiness check: 15 questions from every exam domain in 20 minutes, with your score per domain.

  • 20 minutes
  • 15 questions
  • Free with an account

More Terraform Associate (004) practice by topic

Back to the Terraform Associate (004) practice test →

Independent practice material written from the official exam guide. Not affiliated with or endorsed by the exam provider.