amazon-web-servicesterraform-provider-awsvpc-endpoint

Pass an Output Value into a Data Block


I'd like to pass an output value into a data block but don't know how

output "vpce_interface_ids" {
  value = join(",", aws_vpc_endpoint.vpce.network_interface_ids)
}

data "aws_network_interface" "ENI_0" {
  id = ""
}

Solution

  • You don't really need to do that.

    If your scope is to pass join(",",aws_vpc_endpoint.vpce.network_interface_ids) as id in datasource you can use a local block or pass it directly

    Option 1

    locals {
      id = join(",", aws_vpc_endpoint.vpce.network_interface_ids)
    }
    
    data "aws_network_interface" "ENI_0" {
      id = local.id
    }
    

    Option 2

    data "aws_network_interface" "ENI_0" {
      id = join(",", aws_vpc_endpoint.vpce.network_interface_ids)
    }