Reputation: 103
I have a directory name "3-tier" In which there are two more directories namely ec2 and vpc. The exact directory structure is as attached below
The main.tf in vpc directory has a locals block defined:
locals {
owner = var.owner
environment = var.environment
Name = "${local.owner}-${local.environment}-${var.vpc_name}"
common_tags = {
Owner = local.owner
Environment = local.environment
Name = local.Name
}
}
In the ec2 directory main.tf file I have loaded the module as below
module "vpc_module" {
source = "../vpc/"
}
How can I refer to the locals present in vpc directory main.tf file from ec2 directory main.tf file?
Upvotes: 4
Views: 4158
Reputation: 238199
How can I refer to the locals present in vpc directory main.tf file from ec2 directory main.tf file?
You can't do this directly. You have to add them as output
values to your vpc
module. Then you will be able to access them through outputs of your vpc module.
Upvotes: 4