Skip to content

Outputs

When you use Terraform Cloud with module and configuration files, the outputs from the module are captured and made available as output variables in the Terraform Cloud workspace. These output variables can then be used in other Terraform configurations or modules.


image

To demonstrate, we can use Terraform code that associates an AWS route table with a subnet and it gets the route table ID from the output of the module that created the route table.

resource "aws_route_table" "this" {
  vpc_id = var.vpc_id
  route {
    cidr_block = var.route_table_cidr
    gateway_id = var.gateway_id
  }

output "route_table_igw_id" {
  description = "The ID of the IGW route table"
  value       = aws_route_table.this.id
}
Reusable Module.tf

module "aws_route_table_association-public" {
  source  = "app.terraform.io/grinntec-aws/aws_route_table_association/aws"
  version = "~>0.1.0"
  subnet_id      = module.aws_subnet-public.subnet_id
  route_table_id = module.aws_route_table_igw.route_table_igw_id
}
Configuration Module