0
0
Terraformcloud~10 mins

Prevent_destroy lifecycle rule in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a lifecycle block that prevents resource destruction.

Terraform
resource "aws_s3_bucket" "example" {
  bucket = "my-example-bucket"

  lifecycle {
    [1] = true
  }
}
Drag options to blanks, or click blank then click option'
Acreate_before_destroy
Bprevent_destroy
Cignore_changes
Dreplace_triggered_by
Attempts:
3 left
💡 Hint
Common Mistakes
Using ignore_changes instead of prevent_destroy
Forgetting to set the value to true
Using create_before_destroy which controls replacement order
2fill in blank
medium

Complete the lifecycle block to prevent destroying the resource.

Terraform
lifecycle {
  [1] = true
}
Drag options to blanks, or click blank then click option'
Areplace_triggered_by
Bcreate_before_destroy
Cignore_changes
Dprevent_destroy
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing with ignore_changes which ignores attribute changes
Using create_before_destroy which affects replacement order
3fill in blank
hard

Fix the error in the lifecycle block to correctly prevent resource destruction.

Terraform
lifecycle {
  prevent_destroy = [1]
}
Drag options to blanks, or click blank then click option'
A"false"
Bfalse
Ctrue
D"true"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around true or false which makes it a string
Setting prevent_destroy to false which disables protection
4fill in blank
hard

Fill both blanks to add a lifecycle block that prevents destroying and ignores changes to tags.

Terraform
lifecycle {
  [1] = true
  [2] = ["tags"]
}
Drag options to blanks, or click blank then click option'
Aprevent_destroy
Bignore_changes
Ccreate_before_destroy
Dreplace_triggered_by
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up ignore_changes and create_before_destroy
Not using a list for ignore_changes value
5fill in blank
hard

Fill all three blanks to add a lifecycle block that prevents destroying, creates before destroy, and ignores changes to tags.

Terraform
lifecycle {
  [1] = true
  [2] = true
  [3] = ["tags"]
}
Drag options to blanks, or click blank then click option'
Aprevent_destroy
Bcreate_before_destroy
Cignore_changes
Dreplace_triggered_by
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing create_before_destroy with prevent_destroy
Not using a list for ignore_changes
Setting boolean values as strings