Skip to content

Commit

Permalink
vpn: change use of vpn_gateway_id
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jun 16, 2022
1 parent 4ace110 commit 0a0d06d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@
- flowlogs
- change template to use account_alias

* 2.0.3 -- 2022-06-16
- vpn
- change use of vpn_gateway_id
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
_module_version = "2.0.2"
_module_version = "2.0.3"
_module_names = {
"_main_" = "aws-vpc-setup"

Expand Down
14 changes: 7 additions & 7 deletions vpn/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ locals {
"boc:created_by" = "terraform"
}

vpn_gateway = element(concat(aws_vpn_gateway.vpn[*].id, []), 0)
# vpn_gateway = element(concat(aws_vpn_gateway.vpn[*].id, []), 0)
}


Expand All @@ -78,7 +78,7 @@ resource "aws_vpn_gateway" "vpn" {
resource "aws_vpn_gateway_attachment" "vpn" {
count = var.create ? 1 : 0
vpc_id = var.vpc_id
vpn_gateway_id = local.vpn_gateway
vpn_gateway_id = var.create ? aws_vpn_gateway.vpn[0].id : null
}

#---
Expand Down Expand Up @@ -112,10 +112,10 @@ resource "random_string" "tunnel_preshared_key" {
# at this time, static routing is not an option. We can re-code this later if needed
#---
resource "aws_vpn_connection" "vpn" {
for_each = var.create ? local.vpn_settings : {}
type = "ipsec.1"
# vpn_gateway_id = aws_vpn_gateway.vpn.id
vpn_gateway_id = local.vpn_gateway
for_each = var.create ? local.vpn_settings : {}
type = "ipsec.1"
vpn_gateway_id = var.create ? aws_vpn_gateway.vpn[0].id : null

customer_gateway_id = aws_customer_gateway.vpn[each.key].id
tunnel1_preshared_key = length(var.custom_preshared_keys) == 0 ? random_string.tunnel_preshared_key[each.key].result : element(var.custom_preshared_keys, 0)
tunnel2_preshared_key = length(var.custom_preshared_keys) == 0 ? random_string.tunnel_preshared_key[each.key].result : element(var.custom_preshared_keys, 1)
Expand Down Expand Up @@ -155,7 +155,7 @@ resource "aws_vpn_gateway_route_propagation" "vpn" {
for_each = var.create ? { for v in local.vpn_route_table_ids : "${v.site}.${v.route_table_id}" => v } : {}

# vpn_gateway_id = aws_vpn_gateway.vpn.id
vpn_gateway_id = local.vpn_gateway
vpn_gateway_id = var.create ? aws_vpn_gateway.vpn[0].id : null
route_table_id = each.value.route_table_id
}

Expand Down

0 comments on commit 0a0d06d

Please sign in to comment.