0
0
Terraformcloud

Create_before_destroy lifecycle rule in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the create_before_destroy lifecycle rule do in Terraform?
It tells Terraform to create the new resource before destroying the old one, helping to avoid downtime during updates.
Click to reveal answer
beginner
Why is create_before_destroy useful for resources like load balancers or instances?
Because it ensures the new resource is ready before the old one is removed, preventing service interruptions.
Click to reveal answer
beginner
How do you enable create_before_destroy in a Terraform resource block?
By adding a lifecycle block with create_before_destroy = true inside the resource definition.
Click to reveal answer
intermediate
What happens if create_before_destroy is not set and a resource needs replacement?
Terraform destroys the old resource first, which can cause downtime or service disruption.
Click to reveal answer
intermediate
Can create_before_destroy be used with all Terraform resources?
No, some resources do not support it due to provider or resource limitations.
Click to reveal answer
What is the main benefit of using create_before_destroy in Terraform?
AIt creates the new resource before destroying the old one to avoid downtime.
BIt destroys the resource immediately without creating a new one.
CIt delays resource creation until after destruction.
DIt disables resource replacement.
Where do you place the create_before_destroy setting in Terraform?
AInside the <code>output</code> block.
BInside the <code>provider</code> block.
CInside the <code>variable</code> block.
DInside the <code>resource</code> block's <code>lifecycle</code> block.
What might happen if you don't use create_before_destroy for a critical resource update?
AThe old resource is destroyed before the new one is ready, causing downtime.
BTerraform will automatically enable <code>create_before_destroy</code>.
CTerraform will skip the update.
DTerraform will create two resources.
Is create_before_destroy always supported by all Terraform providers?
AYes, all providers support it.
BOnly for AWS resources.
CNo, some providers or resources do not support it.
DOnly for Google Cloud resources.
Which of these is a correct example of enabling create_before_destroy?
Aresource "aws_instance" "example" { create_before_destroy = true }
Bresource "aws_instance" "example" { lifecycle { create_before_destroy = true } }
Cprovider "aws" { create_before_destroy = true }
Dvariable "create_before_destroy" { default = true }
Explain how the create_before_destroy lifecycle rule helps prevent downtime during resource updates in Terraform.
Think about what happens when replacing a resource without this rule.
You got /3 concepts.
    Describe where and how to configure the create_before_destroy rule in a Terraform resource.
    Look for the lifecycle settings inside the resource.
    You got /3 concepts.