Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubleshooting vpc connection vpn_gateway_id null issue #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
data "aws_vpn_gateway" "default" {
count = var.create_vpn_gateway == "true" ? 1 : 0
count = var.create_vpn_gateway == true ? 1 : 0
attached_vpc_id = var.vpc_id
}
# https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html
resource "aws_vpn_gateway" "default" {
count = var.transit_gateway_id != null ? (var.create_vpn_gateway ? 1 : 0) : 0
count = var.transit_gateway_id == null ? (var.create_vpn_gateway ? 1 : 0) : 0
vpc_id = var.vpc_id
amazon_side_asn = var.vpn_gateway_amazon_side_asn
tags = merge(
Expand All @@ -30,7 +30,7 @@ resource "aws_customer_gateway" "default" {

# https://www.terraform.io/docs/providers/aws/r/vpn_connection.html
resource "aws_vpn_connection" "default" {
vpn_gateway_id = try(lenght(aws_vpn_gateway.default.*.id) > 0 ? aws_vpn_gateway.default.*.id : var.create_vpn_gateway ? data.aws_vpn_gateway.default[0].id : null, null)
vpn_gateway_id = try(aws_vpn_gateway.default[0].id, var.create_vpn_gateway ? data.aws_vpn_gateway.default[0].id : null, null)
customer_gateway_id = join("", aws_customer_gateway.default.*.id)
transit_gateway_id = try(var.transit_gateway_id, null)
type = var.ipsec_type
Expand Down
Loading