-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Extended aws_vpn_gateway use case. #67
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,6 @@ resource "aws_route_table" "public" { | |
count = "${length(var.public_subnets) > 0 ? 1 : 0}" | ||
|
||
vpc_id = "${aws_vpc.this.id}" | ||
propagating_vgws = ["${var.public_propagating_vgws}"] | ||
|
||
tags = "${merge(var.tags, var.public_route_table_tags, map("Name", format("%s-public", var.name)))}" | ||
} | ||
|
@@ -78,7 +77,6 @@ resource "aws_route_table" "private" { | |
count = "${max(length(var.private_subnets), length(var.elasticache_subnets), length(var.database_subnets), length(var.redshift_subnets))}" | ||
|
||
vpc_id = "${aws_vpc.this.id}" | ||
propagating_vgws = ["${var.private_propagating_vgws}"] | ||
|
||
tags = "${merge(var.tags, var.private_route_table_tags, map("Name", format("%s-private-%s", var.name, element(var.azs, count.index))))}" | ||
|
||
|
@@ -333,3 +331,24 @@ resource "aws_vpn_gateway" "this" { | |
|
||
tags = "${merge(var.tags, map("Name", format("%s", var.name)))}" | ||
} | ||
|
||
resource "aws_vpn_gateway_attachment" "vgw" { | ||
count = "${var.attach_vpn_gateway != "default" ? 1 : 0}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this PR to support the conditional creation of VPC, which I have introduced earlier today. ( |
||
|
||
vpc_id = "${aws_vpc.this.id}" | ||
vpn_gateway_id = "${var.attach_vpn_gateway}" | ||
} | ||
|
||
resource "aws_vpn_gateway_route_propagation" "public" { | ||
count = "${var.public_propagating_vgws && var.enable_vpn_gateway || var.public_propagating_vgws && var.attach_vpn_gateway != "default " ? length(var.public_subnets) : 0}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar here, as for private |
||
|
||
route_table_id = "${element(aws_route_table.public.*.id, count.index)}" | ||
vpn_gateway_id = "${element(concat(aws_vpn_gateway.this.*.id, aws_vpn_gateway_attachment.vgw.*.vpn_gateway_id), count.index)}" | ||
} | ||
|
||
resource "aws_vpn_gateway_route_propagation" "private" { | ||
count = "${var.private_propagating_vgws && var.enable_vpn_gateway || var.private_propagating_vgws && var.attach_vpn_gateway != "default" ? length(var.private_subnets) : 0}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
route_table_id = "${element(aws_route_table.private.*.id, count.index)}" | ||
vpn_gateway_id = "${element(concat(aws_vpn_gateway.this.*.id, aws_vpn_gateway_attachment.vgw.*.vpn_gateway_id), count.index)}" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,14 +102,19 @@ variable "enable_vpn_gateway" { | |
default = false | ||
} | ||
|
||
variable "attach_vpn_gateway" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
description = "ID of VPN Gateway to attach to the VPC" | ||
default = "default" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
variable "private_propagating_vgws" { | ||
description = "A list of VGWs the private route table should propagate" | ||
default = [] | ||
description = "Should be true if you want route table propagation" | ||
default = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable type is changed from list to boolean. Usually, it makes more sense to keep backward compatibility for as long as possible, but here I don't see how we can make it. If you have a suggestion, please tell.
|
||
} | ||
|
||
variable "public_propagating_vgws" { | ||
description = "A list of VGWs the public route table should propagate" | ||
default = [] | ||
description = "Should be true if you want route table propagation" | ||
default = false | ||
} | ||
|
||
variable "tags" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
vgw
tothis
. VPN gateway has at most just one attachment.