July 2017
Beginner
208 pages
5h 10m
English
Another useful construct that Terraform provides are outputs. In an output, you define which data you want to be returned by the module. Add the following line to the very bottom of the ./modules/application/application.tf file:
output "hostname" {
value = "${aws_instance.app-server.private_dns}"
}
Now you can use this output inside the template.tf like this:
module "crazy_foods" {
source = "./modules/application"
vpc_id = "${aws_vpc.my_vpc.id}"
subnet_id = "${aws_subnet.public.id}"
name = "CrazyFoods ${module.mighty_trousers.hostname}"
}
Besides the obvious ability to get data from the module, there is another use case for module outputs: forcing dependencies. Here is the graph before passing the output ...
Read now
Unlock full access