Recall & Review
beginner
What is a module input variable in Terraform?
A module input variable is a way to pass values into a Terraform module so it can be customized when used. Think of it like giving a recipe different ingredients to change the final dish.
Click to reveal answer
beginner
How do you define a variable inside a Terraform module?
You define a variable using the
variable block with a name and optionally a type and default value. For example:<br>variable "region" {
type = string
default = "us-west-1"
}Click to reveal answer
beginner
How do you pass a value to a module input variable when calling a module?
You pass values by specifying the variable name and value inside the module block. For example:<br>
module "my_module" {
source = "./modules/example"
region = "us-east-1"
}Click to reveal answer
intermediate
What happens if you do not provide a value for a module input variable that has no default?
Terraform will show an error and stop because it needs a value to use. It's like missing an important ingredient in a recipe.
Click to reveal answer
beginner
Why is it good practice to use variables in Terraform modules?
Variables make modules reusable and flexible. You can use the same module with different settings without changing the module code, just by passing different inputs.
Click to reveal answer
How do you define a string variable named "env" with a default value "dev" in a Terraform module?
✗ Incorrect
The correct syntax uses the variable block with type and default inside the module.
What is the purpose of module input variables in Terraform?
✗ Incorrect
Input variables allow passing values into modules to make them flexible.
If a module variable has no default and you don't provide a value, what happens?
✗ Incorrect
Terraform requires a value for variables without defaults and will error if missing.
How do you pass a value to a module variable named "region" when calling the module?
✗ Incorrect
You assign the variable name and value inside the module block.
Why should you use variables in Terraform modules?
✗ Incorrect
Variables allow modules to be reused with different configurations.
Explain how to create and use input variables in a Terraform module.
Think about how you give a module different settings when you use it.
You got /4 concepts.
Describe what happens if a required module input variable is not provided a value.
What if you forget an important ingredient in a recipe?
You got /3 concepts.