Terraform Authoring and Operations Professional Free Sample Questions

Description

Covers managing the Terraform resource lifecycle, dynamic configuration with data sources and HCL functions, collaborative workflows and remote state, module authoring, and HCP Terraform.

17 free sample questions216 in the full practice test

Try simulator

TAO-Pro Sample Questions

  1. Question 1

    Intermediate

    Manage Resource Lifecycle · Manage resource state, including importing resources and reconciling resource drift

    You are the Lead Terraform Architect for a financial services firm. You are refactoring a large monolithic configuration into smaller, reusable modules to improve maintainability. One specific resource, an aws_s3_bucket named logs, needs to be moved from the root configuration into a new child module named audit_logs. You must ensure that the existing bucket is NOT destroyed and recreated during this refactoring process, as it contains petabytes of compliance data. Which configuration block should you add to your root module to facilitate this state migration?

    Answer and explanation

    Correct answer: D

    The moved block allows you to refactor infrastructure code without destroying and recreating resources. By specifying the from address (the old resource location) and the to address (the new location inside the module), Terraform interprets the change as a rename in the state file rather than a create/destroy action.

  2. Question 2

    Advanced

    Manage Resource Lifecycle · Manage resource state, including importing resources and reconciling resource drift

    A DevOps engineer is tasked with importing a legacy EC2 instance into a Terraform configuration. The engineer has written the resource "aws_instance" "legacy" {} block but does not know the exact instance ID required for the import. However, they know the instance has a specific tag Role = "LegacyApp". Which approach allows the engineer to import this resource using Terraform 1.5+ declarative import syntax without manually looking up the ID first?

    Answer and explanation

    Correct answer: B

    Terraform 1.5+ import blocks allow the id field to be an expression that references other values, including data sources. This allows dynamic resolution of the ID based on tags before the import occurs.

  3. Question 3

    Intermediate

    Develop and Troubleshoot Dynamic Configuration · Use meta-arguments in configuration

    You are managing a critical production environment where applying a configuration that accidentally changes the user_data of an EC2 instance would trigger a replacement, causing unacceptable downtime. You want to ensure that any future terraform apply fails if it attempts to replace this specific instance due to a change in user_data. Which lifecycle configuration should you apply?

    Answer and explanation

    Correct answer: C

    Using ignore_changes instructs Terraform to ignore differences between the configuration and the live state for the specified attributes. If the user_data in config changes, Terraform will simply ignore it and NOT trigger a replacement. This achieves the goal of preventing downtime caused by this specific change.

  4. Question 4

    Beginner

    Develop Collaborative Terraform Workflows · Manage the Terraform binary, providers, and modules using version constraints

    A team is using a Terraform configuration that utilizes the hashicorp/aws provider. They need to ensure that the configuration is compatible with any version of the provider that is at least version 5.0.0 but less than 6.0.0. Which version constraint string correctly expresses this requirement?

    Answer and explanation

    Correct answer: A

    The pessimistic constraint operator ~> allows the rightmost version component to increment. ~> 5.0 allows 5.1, 5.2, etc., but does not allow 6.0. This is equivalent to >= 5.0, < 6.0.

  5. Question 5

    Intermediate

    Develop and Troubleshoot Dynamic Configuration · Use language features to validate configuration

    You are developing a Terraform module that creates an S3 bucket. You want to validate that the bucket name passed via the input variable bucket_name meets AWS naming requirements: it must be between 3 and 63 characters long and must start with a lowercase letter or number. You decide to use a validation block within the variable declaration. Which configuration correctly implements this?

    Answer and explanation

    Correct answer: A

    This validation block uses length() to check the size constraints and can(regex(...)) to verify the starting character. The condition must return true for valid inputs.

  6. Question 6

    Advanced

    Develop and Troubleshoot Dynamic Configuration · Configure input variables and outputs, including complex types

    You are creating a reusable Terraform module for an AWS VPC. The module must accept a list of subnet objects, where each object has a cidr (string) and an optional tags (map of strings). If tags is omitted, it should default to an empty map. Which type constraint correctly defines this input variable using Terraform's optional object attributes feature?

    Answer and explanation

    Correct answer: B

    The optional(type, default) syntax allows you to mark an object attribute as optional. If the attribute is missing, Terraform inserts the provided default value (an empty map {} in this case). This is the correct way to handle optional complex attributes.

  7. Question 7

    Beginner

    Configure and Use Terraform Providers · Troubleshoot provider errors

    During a terraform apply, you encounter a provider error related to API rate limiting. You need to gather more detailed information about the HTTP requests being made by the AWS provider to debug the issue. Which environment variable should you set to enable the most verbose logging specifically for Terraform core and providers?

    Answer and explanation

    Correct answer: A

    TF_LOG is the standard environment variable to control logging. TRACE is the most verbose level, showing detailed internal logs including HTTP requests and responses from providers.

  8. Question 8

    Beginner

    Develop Collaborative Terraform Workflows · Configure remote state

    You are managing a Terraform configuration that uses a local backend. You have been tasked with migrating this state to an S3 backend with DynamoDB locking. After configuring the backend "s3" block in your terraform.tf file, what is the next command you must run to successfully migrate the existing state data to the new backend?

    Answer and explanation

    Correct answer: C

    When the backend configuration changes, terraform init detects the change. To copy the existing state data from the old backend (local) to the new one (S3), you must run terraform init. While terraform init alone often prompts for migration, explicitly using -migrate-state (or confirming the prompt) is the specific action required to move the data.

Register free for 9 more questions

Or unlock all 216 TAO-Pro questions with explanations, timed mode and flashcards.