0
0
Terraformcloud~20 mins

Plan and apply separation in pipelines in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Pipeline Separation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Why separate Terraform plan and apply stages in CI/CD pipelines?

Consider a CI/CD pipeline that runs Terraform to manage infrastructure. Why is it important to separate the plan and apply stages into different pipeline steps?

ATo avoid storing the Terraform state file between stages
BBecause Terraform cannot run plan and apply in the same pipeline
CTo speed up the pipeline by running both stages in parallel
DTo allow manual review and approval of planned changes before applying them
Attempts:
2 left
💡 Hint

Think about safety and control when changing infrastructure.

Configuration
intermediate
2:00remaining
Which Terraform CLI command outputs a plan file for later apply?

In a pipeline, you want to generate a plan file that can be applied later. Which Terraform command correctly creates this plan file?

Aterraform plan --save=tfplan.binary
Bterraform apply -out=tfplan.binary
Cterraform plan -out=tfplan.binary
Dterraform apply --plan=tfplan.binary
Attempts:
2 left
💡 Hint

Look for the command that generates a plan file without applying.

service_behavior
advanced
2:00remaining
What happens if you run 'terraform apply' without a saved plan file in a pipeline?

In a pipeline where plan and apply are separated, what is the behavior if the apply stage runs terraform apply without specifying a saved plan file?

ATerraform will prompt for manual confirmation before applying
BTerraform will create a new plan and apply it immediately without review
CTerraform will apply the last saved plan automatically
DTerraform will fail with an error because no plan file is provided
Attempts:
2 left
💡 Hint

Consider what happens when no plan file is given.

security
advanced
2:00remaining
How to securely share Terraform plan files between pipeline stages?

You want to share the Terraform plan file generated in the plan stage with the apply stage in a CI/CD pipeline. What is the best practice to securely handle this file?

AStore the plan file as a pipeline artifact with restricted access and use encryption if supported
BCommit the plan file to the source code repository for easy access
CSend the plan file via email to the apply stage executor
DGenerate the plan file again in the apply stage to avoid sharing
Attempts:
2 left
💡 Hint

Think about secure file transfer and access control in pipelines.

Best Practice
expert
3:00remaining
What is the recommended approach to handle Terraform state in separated plan and apply pipeline stages?

In a pipeline with separated plan and apply stages, how should Terraform state be managed to ensure consistency and avoid conflicts?

AUse a remote backend (e.g., S3, Terraform Cloud) to store state accessible by both stages
BStore the state file locally in the pipeline workspace and pass it between stages
CGenerate a new state file in each stage to isolate changes
DDo not use state files; rely on manual tracking of infrastructure
Attempts:
2 left
💡 Hint

Think about shared access and locking for state files.