7. Terraform Output

We can specify certain values in output block which are printed when the config file is applied

resource "aws_eip" "one" {
  vpc = true
  network_interface = aws_network_interface.web-server-nic.id
  associate_with_private_ip = "10.0.1.50"
  depends_on = [ aws_internet_gateway.gw, aws_instance.web-server-instance ]
}

output "server_public_ip" {
    value = aws_eip.one.public_ip
}

In above example, upon applying the config file, public ip of NIC will be printed on the terminal.

Last updated