0
0
Terraformcloud~20 mins

Auto-approve flag and its danger in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Auto-approve Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does the auto-approve flag do in Terraform?

When you run terraform apply with the -auto-approve flag, what happens?

ATerraform applies changes immediately without asking for confirmation.
BTerraform asks for manual approval before applying changes.
CTerraform only plans changes but does not apply them.
DTerraform destroys all resources without confirmation.
Attempts:
2 left
💡 Hint

Think about what 'auto' and 'approve' mean together.

security
intermediate
1:30remaining
What is a key risk of using the auto-approve flag in Terraform?

Why can using -auto-approve be dangerous in production environments?

AIt can apply unintended destructive changes without manual review.
BIt prevents Terraform from creating any resources.
CIt disables logging of Terraform actions.
DIt causes Terraform to ignore the state file.
Attempts:
2 left
💡 Hint

Consider what happens if you skip the manual check step.

service_behavior
advanced
2:00remaining
What happens if you run terraform apply -auto-approve after modifying a resource to be destroyed?

Given a Terraform configuration where a resource is changed to be removed, what is the behavior when applying with -auto-approve?

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
}

# Later, this resource is removed from the config

# Running: terraform apply -auto-approve
ATerraform throws an error and stops.
BTerraform plans the destruction but waits for manual approval.
CTerraform ignores the removal and keeps the resource.
DTerraform immediately destroys the resource without asking for confirmation.
Attempts:
2 left
💡 Hint

Think about what skipping approval means for destructive actions.

Best Practice
advanced
2:00remaining
Which practice helps reduce risks when using the auto-approve flag?

To safely use -auto-approve in automation, what should you do?

AAlways run <code>terraform apply -auto-approve</code> without planning.
BDisable state locking to speed up apply.
CRun <code>terraform plan</code> separately and review output before applying.
DUse <code>-auto-approve</code> only on destroy commands.
Attempts:
2 left
💡 Hint

Think about how to catch mistakes before applying changes.

Architecture
expert
2:30remaining
In a CI/CD pipeline, what is a safe way to use the auto-approve flag?

You want to automate Terraform deployments in a pipeline but avoid accidental destructive changes. Which approach is safest?

ARun <code>terraform apply -auto-approve</code> directly on every commit.
BRun <code>terraform plan</code> and require manual approval before running <code>terraform apply -auto-approve</code>.
CDisable state locking to allow parallel applies with auto-approve.
DUse <code>-auto-approve</code> only on the destroy stage without planning.
Attempts:
2 left
💡 Hint

Consider how to balance automation and safety in pipelines.