HashiCorp Terraform Associate (004) Question 5
Single answer1 Infrastructure as Code (IaC) with TerraformA platform team manages its AWS networking stack with Terraform. Today, developers sometimes create VPCs and subnets manually in the AWS console, and the resulting environments are inconsistent across teams. The platform lead wants a repeatable approach where the desired infrastructure is defined in version-controlled files, reviewed through pull requests, and then provisioned consistently in multiple environments using the same workflow. Which Terraform practice best addresses this requirement?
- A
Define the networking resources in Terraform configuration files, store them in version control, and use Terraform plans and applies to provision the environments.
- B
Use the AWS console to create the initial networking resources, then periodically export screenshots and documentation so teams can reproduce the setup manually.
- C
Write shell scripts that call the AWS CLI to create each resource, because scripts are easier to change than declarative Terraform configuration.
- D
Create the resources once in a shared AWS account and tell application teams to copy the settings manually into their own accounts when needed.
Show answer and explanation
Correct answer: A
Explanation
The best answer is to define infrastructure in Terraform configuration files and manage those files in version control. This is the essence of Infrastructure as Code: infrastructure is described as code, reviewed like application code, and provisioned through a repeatable workflow. In Terraform, practitioners typically write .tf files, run terraform plan to preview changes, and run terraform apply to create or update resources. This approach improves consistency across environments, supports collaboration through pull requests, and reduces manual errors and drift. HashiCorp documentation and Terraform best practices consistently emphasize declarative configuration, version control, and repeatable execution workflows as key benefits of using Terraform for IaC.
- A. Correct.
Correct. This is the core Infrastructure as Code workflow with Terraform. Terraform configuration files define the desired state declaratively, version control provides change history and code review, and Terraform plan/apply enables consistent provisioning across environments. This directly addresses repeatability, collaboration, and reduced configuration drift.
- B. Incorrect.
Incorrect. Documentation and screenshots do not provide executable, versioned infrastructure definitions. Manual recreation is error-prone and does not solve consistency, auditability, or repeatability problems that IaC is designed to address.
- C. Incorrect.
Incorrect. AWS CLI scripts can automate tasks, but they are typically imperative rather than declarative and do not provide Terraform's state management, execution plan, dependency graph, and standardized IaC workflow. A candidate might choose this because scripts do automate infrastructure, but they do not best satisfy the requirement for consistent declarative IaC with Terraform.
- D. Incorrect.
Incorrect. Manually copying settings between accounts is not Infrastructure as Code and increases the risk of drift and human error. It also makes review, reuse, and repeatable deployment difficult.