0
0
Terraformcloud~5 mins

Module outputs in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a module output in Terraform?
A module output is a way to expose values from a Terraform module so that they can be used by the root module or other modules. It acts like a window to see important information from inside the module.
Click to reveal answer
beginner
How do you define an output in a Terraform module?
You define an output using the output block with a name and a value. For example:<br>
output "instance_ip" {<br>  value = aws_instance.example.public_ip<br>}
Click to reveal answer
beginner
Why should you use outputs in Terraform modules?
Outputs help share important information like IP addresses, IDs, or URLs from a module to other parts of your configuration or to users. This makes your infrastructure easier to connect and manage.
Click to reveal answer
beginner
How do you access a module output in the root module?
You access it using the syntax module.<module_name>.<output_name>. For example, if your module is called webserver and output is instance_ip, you use module.webserver.instance_ip.
Click to reveal answer
intermediate
Can module outputs be sensitive? How do you mark them?
Yes, outputs can be marked as sensitive by adding sensitive = true inside the output block. This hides the value from Terraform's normal output to protect secrets.
Click to reveal answer
What is the purpose of an output block in a Terraform module?
ATo expose values from the module for use elsewhere
BTo define variables inside the module
CTo create resources in the module
DTo delete resources after deployment
How do you reference an output named 'db_password' from a module called 'database'?
Avar.database.db_password
Bmodule.database.db_password
Coutput.database.db_password
Dresource.database.db_password
Which keyword marks an output as sensitive in Terraform?
Asensitive = true
Bhidden = true
Cprivate = true
Dsecret = true
What happens if you do not define outputs in a module?
AOutputs are automatically created
BTerraform will throw an error
CYou cannot access any values from the module externally
DThe module will not create resources
Which of the following is a valid output block in Terraform?
Aoutput name = var.name
Boutput name { value = var.name }
Coutput "name" = var.name
Doutput "name" { value = var.name }
Explain how Terraform module outputs help in connecting different parts of infrastructure.
Think about how you share important info from one part to another.
You got /4 concepts.
    Describe how to define and use a sensitive output in a Terraform module.
    Consider how to hide passwords or keys in outputs.
    You got /4 concepts.