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

Extended aws_vpn_gateway use case. #67

Merged
merged 3 commits into from
Feb 10, 2018
Merged

Extended aws_vpn_gateway use case. #67

merged 3 commits into from
Feb 10, 2018

Conversation

robh007
Copy link
Contributor

@robh007 robh007 commented Feb 3, 2018

This extends using the aws_vpn_gateway_route_propagation resource and closes #9

Previously if you enabled a VPN gateway there was no way to use that gateway within this module. You could also pass in a list of VGWs to associate with a route table type (Public / Private). However this wouldn't have worked either because you need to attach a VGW to a VPC to then allow a route table to turn on route propagation.

Also a VPC can only ever have 1 VGW attached to it. So I'm struggling to understand why a list of VGWs is expected to be passed in when you are only creating 1 VPC.

  • added new variable attach_vpn_gateway
  • added new resource aws_vpn_gateway_attach
  • modified aws_vpn_gateway_route_propagation usage

@robh007
Copy link
Contributor Author

robh007 commented Feb 9, 2018

Hi @antonbabenko,

Is this something you can look at / comment on?

Thanks
Rob.

@antonbabenko
Copy link
Member

Yes, @robh007 , I looked at it already briefly. I will be able to take another look and respond properly in a few hours. Sorry for the delay!

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good in my opinion, few comments here and there. Lets hear what @patkar thinks.

variables.tf Outdated
@@ -102,14 +102,19 @@ variable "enable_vpn_gateway" {
default = false
}

variable "attach_vpn_gateway" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vpn_gateway_id is a better name for such variable

variables.tf Outdated
description = "A list of VGWs the private route table should propagate"
default = []
description = "Should be true if you want route table propagation"
default = false
Copy link
Member

Choose a reason for hiding this comment

The 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.

private_propagating_vgws should be renamed to propagate_private_route_tables_vgw (or smth like that).

public_propagating_vgws should be renamed to propagate_public_route_tables_vgw.

main.tf Outdated
@@ -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" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename vgw to this. VPN gateway has at most just one attachment.

main.tf Outdated
@@ -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}"
Copy link
Member

Choose a reason for hiding this comment

The 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. (count will change in all VPC resources you are adding)

main.tf Outdated
}

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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count can be updated like this:

count = "${var.create_vpc && var.propagate_private_route_tables_vgw && (var.enable_vpn_gateway || var.vpn_gateway_id = "") ? length(var.private_subnets) : 0}"

variables.tf Outdated
@@ -102,14 +102,19 @@ variable "enable_vpn_gateway" {
default = false
}

variable "attach_vpn_gateway" {
description = "ID of VPN Gateway to attach to the VPC"
default = "default"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default = "" is better, because it means "it was not specified".

main.tf Outdated
}

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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here, as for private

@robh007
Copy link
Contributor Author

robh007 commented Feb 10, 2018

Hi @antonbabenko,

I've made the changes you've suggested. I've also changed the public "aws_vpn_gateway_route_propagation" resource from a count of public subnets to 1. This created addtional resources on the same route table.

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Thank you!

@antonbabenko antonbabenko merged commit a907849 into terraform-aws-modules:master Feb 10, 2018
@antonbabenko
Copy link
Member

v1.23.0 has been released

@robh007
Copy link
Contributor Author

robh007 commented Feb 10, 2018

No problem @antonbabenko happy to help.

@github-actions
Copy link

github-actions bot commented Nov 5, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants