Open AsoTora opened 2 years ago
@AsoTora What did you do here? Got the same problem.
@rsabha You can try to use https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpn_gateway#attached_vpc_id
data "aws_vpn_gateway" "default" {
attached_vpc_id = var.vpc_id
}
resource "aws_vpn_gateway" "default" {
# If there is no vpn_gw attached we create a new one
count = data.aws_vpn_gateway.default.id == null ? 1 : 0
vpc_id = var.vpc_id
amazon_side_asn = var.vpn_gateway_amazon_side_asn
tags = {
Name = "${var.vpn_name_prefix}-vpn-gw"
}
}
Did this end up in the code?
@oc-christopher-billett doesn't look like it. @ggorge-etiqa or @AsoTora -- we'd be happy to accept a PR for this. Please put one up if you're interested 👍
Describe the Bug
When using this module for 2d VPN connection on the VPC in my AWS infra I'm getting errors due to the new VPN Gateway trying to be created.
Error: error attaching EC2 VPN Gateway (vgw-***) to VPC (vpc-***): InvalidVpcState: VPC vpc-*** is currently attached to the Virtual Private Gateway.
Expected Behavior
It seems logical for me to be able to configure VPG that is used instead of creating a new one (especially when official VPC module has enable_vpn_gateway feature).
Steps to Reproduce
Steps to reproduce the behaviour:
Code snippets
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas: