Challenge - 5 Problems
Lifecycle Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Configuration
intermediate2:00remaining
Effect of lifecycle ignore_changes on resource updates
Given the following Terraform resource configuration, what will happen if the
tags attribute is changed outside Terraform and then Terraform applies a change to instance_type?resource "aws_instance" "example" {
ami = "ami-123456"
instance_type = "t2.micro"
tags = {
Environment = "dev"
}
lifecycle {
ignore_changes = [tags]
}
}Attempts:
2 left
💡 Hint
Consider what ignore_changes does to attributes changed outside Terraform.
✗ Incorrect
The lifecycle block with ignore_changes on tags tells Terraform to ignore any changes to tags made outside Terraform. Therefore, when instance_type changes, Terraform updates it but leaves tags as they are, not reverting external changes.
❓ Architecture
intermediate2:00remaining
Using lifecycle prevent_destroy to protect critical resources
You have a Terraform-managed database instance that must never be destroyed accidentally. Which lifecycle configuration ensures Terraform will refuse to destroy this resource even if you run
terraform destroy or remove it from the configuration?Attempts:
2 left
💡 Hint
Which lifecycle setting blocks resource destruction?
✗ Incorrect
The prevent_destroy setting in lifecycle blocks Terraform from destroying the resource, causing an error if a destroy is attempted.
❓ service_behavior
advanced2:00remaining
Impact of create_before_destroy on resource replacement
Consider a Terraform resource with the lifecycle block:
What is the behavior when a change requires resource replacement?
lifecycle {
create_before_destroy = true
}What is the behavior when a change requires resource replacement?
Attempts:
2 left
💡 Hint
Think about how create_before_destroy affects resource replacement order.
✗ Incorrect
With create_before_destroy, Terraform creates the replacement resource before destroying the original, minimizing downtime.
❓ security
advanced2:00remaining
Risks of ignoring changes on sensitive attributes
If you configure lifecycle ignore_changes on a sensitive attribute like
password in a database resource, what is a potential risk?Attempts:
2 left
💡 Hint
Consider what ignoring changes means for sensitive data updates.
✗ Incorrect
Ignoring changes on sensitive attributes means Terraform won't apply updates to them, so if the password changes in config, it won't be updated in the real resource, causing drift and potential security issues.
✅ Best Practice
expert3:00remaining
Combining lifecycle blocks for zero-downtime deployment
You want to update an AWS autoscaling group with zero downtime. Which lifecycle configuration combination best supports this goal?
Attempts:
2 left
💡 Hint
Think about how to replace resources safely and avoid scaling interruptions.
✗ Incorrect
create_before_destroy ensures new resources are ready before old ones are removed, and ignoring desired_capacity changes prevents Terraform from resetting scaling during updates, supporting zero downtime.