Recall & Review
beginner
What is the purpose of a
check block in Terraform?A
check block is used to verify conditions during Terraform plan or apply. It ensures that certain rules or assertions are met before continuing, helping catch configuration errors early.Click to reveal answer
beginner
How do you write a simple assertion inside a
check block?Inside a
check block, use the assert keyword followed by a condition. For example: <br>check {
assert var.instance_count > 0
error_message = "Instance count must be greater than zero."
}Click to reveal answer
beginner
What happens if an assertion in a
check block fails during Terraform execution?Terraform stops the plan or apply process and shows the error message defined in the
check block. This prevents invalid infrastructure changes.Click to reveal answer
intermediate
Can
check blocks access variables and resource attributes?Yes,
check blocks can use variables, locals, and resource attributes to make assertions based on the current configuration values.Click to reveal answer
intermediate
Why are
check blocks considered a best practice in Terraform configurations?They help catch mistakes early by validating assumptions and constraints. This reduces errors in infrastructure deployment and improves reliability.
Click to reveal answer
What keyword is used inside a Terraform
check block to verify a condition?✗ Incorrect
The
assert keyword is used inside a check block to verify conditions.What happens if an assertion in a
check block fails?✗ Incorrect
Terraform stops the plan or apply and shows the error message if an assertion fails.
Which of these can a
check block use to make assertions?✗ Incorrect
check blocks can use variables, locals, and resource attributes.Where is a
check block typically placed in Terraform code?✗ Incorrect
check blocks are usually placed at the root module level to validate configuration.Why use
check blocks in Terraform?✗ Incorrect
check blocks validate configuration and catch errors early.Explain how a
check block with assertions improves Terraform configuration reliability.Think about catching mistakes early.
You got /4 concepts.
Describe the syntax and components of a basic
check block with an assertion in Terraform.Focus on how to write the condition and message.
You got /4 concepts.