Cert prep · Terraform Authoring and Operations Pro · AWS DevOps Engineer Pro (DOP-C02)

Lifecycle guardrails, dynamic configuration, modules and reusable IaC

Practice self-check. Answers stay in this page so you can grade yourself. This is not a scored exam.

Ten questions. Objectives: Terraform Pro 2 and 4; DOP-C02 tasks 2.1 and 2.3. Companion lab: Terraform lab 01, lifecycle guardrails.

Lab download. Starter is the tree you edit. Worked answer is a separate file; open it after the starter passes. Terraform exactly 1.10.5. terraform init downloads hashicorp/aws 6.71.0 once, pinned by the shipped lock file. The checker uses a mock provider: no AWS account, no credentials, and no cloud spend. All lab requirements.

Q1 · Terraform Pro objective 2, dynamic configuration
A module for the edge supervisor declares variable "max_restarts" with a validation block whose condition is var.max_restarts >= 1 && var.max_restarts <= 3 and a clear error_message. A teammate runs terraform plan -var max_restarts=5 in CI. What happens?
Q2 · Terraform Pro objective 2, dynamic configuration
A root module must name the audit-ledger table "${var.service}-${var.environment}-ledger" and reuse that name in several resources. A teammate proposes making table_name an input variable whose default is that interpolated string. What is the correct approach?
Q3 · Terraform Pro objective 2, dynamic configuration
The edge ingress aws_security_group has name = "edge-ingress" and lifecycle { create_before_destroy = true }. Changing its description forces a replacement, and the apply fails because a group with that name already exists in the VPC. What is the best fix?
Q4 · Terraform Pro objective 2, dynamic configuration
The audit-ledger aws_dynamodb_table has lifecycle { prevent_destroy = true }. A reviewer asks what this setting guarantees. Which statement is accurate?
Q5 · Terraform Pro objective 2, dynamic configuration
An external autoscaler adjusts read_capacity and write_capacity on the provisioned audit-ledger table, and every terraform plan now shows a diff that would reset them. The team still wants plans to detect drift in every other argument, such as tags. Which configuration is best?
Q6 · Terraform Pro objective 4, modules
A child module edge_sg declares variable "ingress_cidrs" as list(string) with a validation block using alltrue([for c in var.ingress_cidrs : can(cidrnetmask(c))]). A caller passes ["10.0.0.0/33"]. When and how is the problem reported?
Q7 · Terraform Pro objective 4, modules
The root module currently manages aws_security_group.edge. The team moves it into a new child module called edge whose resource is named aws_security_group.this. They want terraform plan to show no destroy and recreate. What should they add?
Q8 · DOP-C02 task 2.1, reusable IaC components
A platform team wants every application team to build the edge ingress security group with the approved ports, tagging and logging settings. Today teams copy a template from a wiki and edit it, and the copies have diverged. Which approach best embeds the governance in a reusable component?
Q9 · DOP-C02 task 2.1, reusable IaC components
A pull request changes the TableName property of the audit-ledger AWS::DynamoDB::Table in a CloudFormation template. The change process requires that engineers confirm whether a stack update will replace any resource before it runs. What should the pipeline do?
Q10 · DOP-C02 task 2.3, automation at scale
A fleet of EC2 instances running the edge service must keep an agent configuration file at an approved state. Engineers occasionally edit the file by hand, and the team wants the approved state reapplied automatically every 30 minutes without logging in. Which solution fits?