July 2017
Beginner to intermediate
358 pages
10h 54m
English
When we are building modules in Terraform, we often need to reference attributes from other modules. There is a clean separation between modules, which means that they cannot directly access another module resources. For example, in this module, we are creating a VPC, and later on, we would like to create an EC2 instance that is attached to this VPC. We could not use the syntax as shown in the upcoming code.
The module2/terraform.tf file contains the following content:
resource "aws_instance" "web" {
# ...
vpc_id = "${aws_vpc.default.id}"
}
The previous example would result in an error because we are trying to reference a variable that does not exist in this module, even though it does exist in your global Terraform config. ...
Read now
Unlock full access