Passing VPC_ID from one Env (ex: Dev) to Another Env (ex: stage)


Here is my framework


VPC Module is like below and Used Outputs to VPC_ID

resource “aws_vpc” “vpc” {


Environments–>Dev–.> is like create VPC
module “vpc” {

source = “…/…/vpc/”


My requirement over here, I needed to pass DEV ENV VPC ID to STAGE ENV to establish VPC Peering.

If its the same environment or means, i’m using below to get id, but is there any way to get passed this VPC_ID dynamically in any another environment like Stage?


It would be grate if you could share any sample example or code, pretty much appreciated.

Thank you so much for your time and kind favor,

Hi @balarajuaws68

You could use Data Source: aws_vpc to search for the ID of the VPC from another Terraform environment, for example if you know the cidr_block, a tag or other VPC unique characteristics.

See documentation at: