Alfa-30ms
Alfa-30ms

Reputation: 1

Attach existing IGW to new VPC via terraform

Our accounts come with IGW created and we only need to attach it to new VPCs that are getting created. I'm building AWS infra with terraform. With terraform import I can make it work but for deploying it to different regions and accounts, I am not happy with the import approach.

I have tried data source but can't really make it work. Furthermore, I even tried using template files with data "template_file" but still couldn't attach IGW to the VPC that is getting created by terraform.

Can you help with any method which I can adopt to attach existing IGW to new VPC via terraform?

Upvotes: 0

Views: 335

Answers (1)

homelessDevOps
homelessDevOps

Reputation: 20726

I think this not possible by AWS.

  • Each VPC can have only one Internet Gateway.
  • Each Internet Gateway can only be attached to one VPC.

You can find the limits here: https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html

I would suggest to delete the existing IGW and create a new one with a proper Terraform module and reuse it on other vpcs.

Upvotes: 1

Related Questions