Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Using outputs from other tf files in terraform

Is there a way of using output values of a module that is located in another folder? Imagine the following environment:

tm-project/
├── lambda
│   └── vpctm-manager.js
├── networking
│   ├── init.tf
│   ├── terraform.tfvars
│   ├── variables.tf
│   └── vpc-tst.tf
├── prd
│   ├── init.tf
│   ├── instances.tf
│   ├── terraform.tfvars
│   └── variables.tf
└── security
    └── init.tf

I want to create EC2 instances and place them in a subnet that is declared in networking folder. So, I was wondering if by any chance I could access the outputs of the module I used in networking/vpc-tst.tf as the inputs of my prd/instances.tf.

Thanks in advances.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use a outputs.tf file to define the outputs of a terraform module. Your output will have the variables name such as the content below.

output "vpc_id" {
  value = "${aws_vpc.default.id}"
}

These can then be referenced within your prd/instances.tf by referencing the resource name combined with the output name you defined in your file.

For example if you have a module named vpc which uses this module you could then use the output similar to below.

module "vpc" {
   ......
}

resource "aws_security_group" "my_sg" {
    vpc_id = module.vpc.vpc_id
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!