Skip to content

Commit

Permalink
Merge pull request #88 from cmassey-berico/master
Browse files Browse the repository at this point in the history
  • Loading branch information
lorengordon authored Oct 30, 2020
2 parents 9782b42 + 8bd38f7 commit d3ff0a0
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 123 deletions.
3 changes: 1 addition & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[bumpversion]
current_version = 1.0.2
current_version = 2.0.0
commit = True
message = Bumps version to {new_version}
tag = False
tag_name = {new_version}

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Terraform module to create a VPN Connection
| amazon\_side\_asn | ASN for the Amazon side of the VPN gateway | `string` | `"64512"` | no |
| cgw\_bgp\_asn | BGP ASN of the customer gateway | `string` | `null` | no |
| cgw\_ip\_addresses | List of IP addresses of the customer gateways | `list(string)` | `[]` | no |
| create\_vpn\_connection | Controls whether to create the VPN resources | `bool` | `true` | no |
| destination\_cidr\_blocks | List of CIDR blocks to route through the VPN Connection | `list` | `[]` | no |
| name | Name tag to associate to all resources that support tags | `string` | `null` | no |
| propagating\_route\_table\_count | Number of route tables in the list of progagating\_route\_table\_ids | `string` | `"0"` | no |
Expand Down
16 changes: 6 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
provider "aws" {
}

locals {
vgw_name = var.name == null ? "VGW" : "VGW_${var.name}"
cgw_name = var.name == null ? "CGW" : "CGW_${var.name}"
vpn_name = var.name == null ? "VPN" : "VPN_${var.name}"
}

resource "aws_vpn_gateway" "this" {
count = var.create_vpn_connection ? 1 : 0

vpc_id = var.vpc_id
amazon_side_asn = var.amazon_side_asn
Expand All @@ -21,7 +17,7 @@ resource "aws_vpn_gateway" "this" {
}

resource "aws_customer_gateway" "this" {
count = var.create_vpn_connection ? length(var.cgw_ip_addresses) : 0
count = length(var.cgw_ip_addresses)

bgp_asn = var.cgw_bgp_asn
ip_address = var.cgw_ip_addresses[count.index]
Expand All @@ -35,9 +31,9 @@ resource "aws_customer_gateway" "this" {
}

resource "aws_vpn_connection" "this" {
count = var.create_vpn_connection ? length(var.cgw_ip_addresses) : 0
count = length(var.cgw_ip_addresses)

vpn_gateway_id = aws_vpn_gateway.this[0].id
vpn_gateway_id = aws_vpn_gateway.this.id
customer_gateway_id = aws_customer_gateway.this[count.index].id
type = "ipsec.1"
static_routes_only = var.static_routes_only
Expand All @@ -50,15 +46,15 @@ resource "aws_vpn_connection" "this" {
}

resource "aws_vpn_connection_route" "this" {
count = var.create_vpn_connection ? length(var.destination_cidr_blocks) : 0
count = length(var.destination_cidr_blocks)

destination_cidr_block = var.destination_cidr_blocks[count.index]
vpn_connection_id = aws_vpn_connection.this[0].id
}

resource "aws_vpn_gateway_route_propagation" "this" {
count = var.create_vpn_connection ? var.propagating_route_table_count : 0
count = var.propagating_route_table_count

vpn_gateway_id = aws_vpn_gateway.this[0].id
vpn_gateway_id = aws_vpn_gateway.this.id
route_table_id = var.propagating_route_table_ids[count.index]
}
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output "vpn_gateway_id" {
description = "ID of the VPN Gateway"
value = join("", aws_vpn_gateway.this.*.id)
value = aws_vpn_gateway.this.id
}

output "customer_gateway_ids" {
Expand Down
25 changes: 0 additions & 25 deletions tests/create_customer_gateway/README.md

This file was deleted.

9 changes: 4 additions & 5 deletions tests/create_customer_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ module "example" {
aws = aws
}

create_vpn_connection = true
name = "tardigrade-vpc-connection-${random_string.this.result}"
vpc_id = module.vpc.vpc_id
cgw_ip_addresses = ["19.1.1.1", "19.1.1.2"]
cgw_bgp_asn = "64511"
name = "tardigrade-vpc-connection-${random_string.this.result}"
vpc_id = module.vpc.vpc_id
cgw_ip_addresses = ["19.1.1.1", "19.1.1.2"]
cgw_bgp_asn = "64511"
}
3 changes: 0 additions & 3 deletions tests/create_customer_gateway/versions.tf

This file was deleted.

25 changes: 0 additions & 25 deletions tests/create_vpn_gateway/README.md

This file was deleted.

5 changes: 2 additions & 3 deletions tests/create_vpn_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module "example" {
aws = aws
}

create_vpn_connection = true
name = "tardigrade-vpn-connection-${random_string.this.result}"
vpc_id = module.vpc.vpc_id
name = "tardigrade-vpn-connection-${random_string.this.result}"
vpc_id = module.vpc.vpc_id
}
3 changes: 0 additions & 3 deletions tests/create_vpn_gateway/versions.tf

This file was deleted.

23 changes: 0 additions & 23 deletions tests/no_create/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions tests/no_create/main.tf

This file was deleted.

3 changes: 0 additions & 3 deletions tests/no_create/versions.tf

This file was deleted.

6 changes: 0 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
variable "create_vpn_connection" {
description = "Controls whether to create the VPN resources"
type = bool
default = true
}

variable "name" {
description = "Name tag to associate to all resources that support tags"
type = string
Expand Down

0 comments on commit d3ff0a0

Please sign in to comment.