Core Terraform Workflow
Execute the write, plan, and apply workflow including initialization, validation, and destruction.
The Core Terraform Workflow consists of three main stages: Write, Plan, and Apply. This workflow represents the fundamental process that practitioners follow when using Terraform to manage infrastructure as code. **Write Stage:** In this initial phase, you author your Terraform configuration files…
Concepts covered: The Write, Plan, Apply workflow, Infrastructure lifecycle with Terraform, The terraform init command, Working directory initialization, Downloading providers and modules, The terraform validate command, Configuration syntax validation, The terraform plan command, Understanding plan output, Plan file generation and usage, The terraform apply command, Apply confirmation and auto-approve, Applying saved plan files, The terraform destroy command, Targeted destruction of resources, The terraform fmt command, Configuration formatting standards
TA-004 - Core Terraform Workflow Example Questions
Test your knowledge of Core Terraform Workflow
Question 1
You are a DevOps engineer at a media streaming company. Your team maintains a Terraform configuration that uses three providers: AWS, Cloudflare, and Datadog. The configuration also references five child modules stored in a private GitLab repository. A new team member clones the repository and attempts to run 'terraform validate' to check the syntax before making changes, but receives an error about uninitialized providers. They then run 'terraform init' and notice it takes several minutes to complete. The team member asks you to explain what operations terraform init performed during those minutes that made the subsequent validate command work. Which response accurately describes the initialization operations that occurred?
Question 2
You are a DevOps engineer at a fintech company responsible for maintaining Terraform configurations. A developer has created a new module that provisions an AWS DynamoDB table with a global secondary index. The module includes the following resource definition: resource "aws_dynamodb_table" "transactions" { name = var.table_name billing_mode = "PAY_PER_REQUEST" hash_key = "transaction_id" attribute { name = "transaction_id" type = "S" } attribute { name = "customer_id" type = "N" } global_secondary_index { name = "CustomerIndex" hash_key = "customer_id" projection_type = "ALL" } } After running terraform init and terraform validate, both commands complete successfully. However, when terraform apply is executed, AWS returns an error indicating that the attribute type for customer_id should be "S" (String) based on the actual data format your application uses. A colleague argues that terraform validate should have detected this type mismatch. What is the correct explanation for this validation behavior?
Question 3
When terraform init encounters a module block with a registry source that includes version constraints, which specific file does Terraform consult first to determine if cached modules satisfy the declared requirements?