Skip to content

Extended aws_vpn_gateway use case.#67

Merged
antonbabenko merged 3 commits intoterraform-aws-modules:masterfrom
robh007:VPN-GATEWAY
Feb 10, 2018
Merged

Extended aws_vpn_gateway use case.#67
antonbabenko merged 3 commits intoterraform-aws-modules:masterfrom
robh007:VPN-GATEWAY

Conversation

@robh007
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

robh007 commented Feb 9, 2018

Hi @antonbabenko,

Is this something you can look at / comment on?

Thanks
Rob.

@antonbabenko
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread variables.tf Outdated
default = false
}

variable "attach_vpn_gateway" {
Copy link
Copy Markdown
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

Comment thread variables.tf
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
Copy Markdown
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.

Comment thread main.tf Outdated
tags = "${merge(var.tags, map("Name", format("%s", var.name)))}"
}

resource "aws_vpn_gateway_attachment" "vgw" {
Copy link
Copy Markdown
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.

Comment thread main.tf Outdated
}

resource "aws_vpn_gateway_attachment" "vgw" {
count = "${var.attach_vpn_gateway != "default" ? 1 : 0}"
Copy link
Copy Markdown
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)

Comment thread 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
Copy Markdown
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}"

Comment thread variables.tf Outdated

variable "attach_vpn_gateway" {
description = "ID of VPN Gateway to attach to the VPC"
default = "default"
Copy link
Copy Markdown
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".

Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

v1.23.0 has been released

@robh007
Copy link
Copy Markdown
Contributor Author

robh007 commented Feb 10, 2018

No problem @antonbabenko happy to help.

@github-actions
Copy link
Copy Markdown

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