Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda