Wednesday, February 21, 2024
HomeSoftware EngineeringThe right way to view a Terraform Module’s Output

The right way to view a Terraform Module’s Output

An output in Terraform is a method to view the results of an motion that has been carried out, or useful resource that has been created.

Let’s say that you’ve some code to create a Load Balancer, or Assign a Public IP. As soon as this motion is full, the output block may have entry to this created worth.

An easy output instance

output "instance_ips" {
  worth = aws_instance.internet.*.public_ip

output "lb_address" {
  worth = aws_alb.internet.public_dns

This may output the values to the console as soon as the terraform apply step has efficiently run.

However what occurs in case you have some outputs in a module that your personal Terraform calls?

Outputs are solely rendered to the fast caller, and never traversed up the decision tree to the initiation

An instance venture construction



In our we name:

module "example_mod" {
  supply  = "./modules/example_mod"

This won’t render any output to the console, because the is segmented to the module itself and never handed up the chain.

To get entry to those outputs after module creation, we have to do the next:

The right way to cross a Module’s Output up the tree to the Guardian


./    # <- add this

In our file:

  worth = module.example_mod.instance_ips

output "THE_LB_ADDRESS" {
  worth = module.example_mod.lb_address


Please enter your comment!
Please enter your name here

Most Popular

Recent Comments