Skip to content

Commit e54337e

Browse files
authored
Initial implementation (#1)
* Init repo * Initial implementation * Address CR
1 parent ae438e1 commit e54337e

File tree

14 files changed

+905
-5
lines changed

14 files changed

+905
-5
lines changed

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
*.tfstate
66
*.tfstate.*
77

8-
# .tfvars files
9-
*.tfvars
8+
# IDE files
9+
.idea
10+
*.iml
11+
12+
# Build harness files
13+
.build-harness
14+
build-harness

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
addons:
2+
apt:
3+
packages:
4+
- git
5+
- make
6+
- curl
7+
8+
install:
9+
- make init
10+
11+
script:
12+
- make terraform/install
13+
- make terraform/get-plugins
14+
- make terraform/get-modules
15+
- make terraform/lint
16+
- make terraform/validate

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2019 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SHELL := /bin/bash
2+
3+
# List of targets the `readme` target should call before generating the readme
4+
export README_DEPS ?= docs/targets.md docs/terraform.md
5+
6+
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
7+
8+
## Lint terraform code
9+
lint:
10+
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate

README.md

Lines changed: 308 additions & 2 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
#
3+
# This is the canonical configuration for the `README.md`
4+
# Run `make readme` to rebuild the `README.md`
5+
#
6+
7+
# Name of this project
8+
name: terraform-aws-vpn-connection
9+
10+
# Tags of this project
11+
tags:
12+
- aws
13+
- terraform
14+
- terraform-modules
15+
- vpc
16+
- subnet
17+
- route
18+
- route-table
19+
- vpn
20+
- vpn-connection
21+
- site-to-site-vpn-connection
22+
- virtual-private-gateway
23+
- customer-gateway
24+
- ip
25+
- ip-address
26+
27+
# Categories of this project
28+
categories:
29+
- terraform-modules/networking
30+
31+
# Logo for this project
32+
#logo: docs/logo.png
33+
34+
# License of this project
35+
license: "APACHE2"
36+
37+
# Canonical GitHub repo
38+
github_repo: cloudposse/terraform-aws-vpn-connection
39+
40+
# Badges to display
41+
badges:
42+
- name: "Build Status"
43+
image: "https://travis-ci.org/cloudposse/terraform-aws-vpn-connection.svg?branch=master"
44+
url: "https://travis-ci.org/cloudposse/terraform-aws-vpn-connection"
45+
- name: "Latest Release"
46+
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-vpn-connection.svg"
47+
url: "https://github.com/cloudposse/terraform-aws-vpn-connection/releases/latest"
48+
- name: "Slack Community"
49+
image: "https://slack.cloudposse.com/badge.svg"
50+
url: "https://slack.cloudposse.com"
51+
52+
related:
53+
- name: "terraform-aws-vpc"
54+
description: "Terraform module that defines a VPC with public/private subnets across multiple AZs with Internet Gateways"
55+
url: "https://github.com/cloudposse/terraform-aws-vpc"
56+
57+
- name: "terraform-aws-vpc-peering"
58+
description: "Terraform module to create a peering connection between two VPCs"
59+
url: "https://github.com/cloudposse/terraform-aws-vpc-peering"
60+
61+
- name: "terraform-aws-kops-vpc-peering"
62+
description: "Terraform module to create a peering connection between a backing services VPC and a VPC created by Kops"
63+
url: "https://github.com/cloudposse/terraform-aws-kops-vpc-peering"
64+
65+
- name: "terraform-aws-dynamic-subnets"
66+
description: "Terraform module for public and private subnets provisioning in existing VPC"
67+
url: "https://github.com/cloudposse/terraform-aws-dynamic-subnets"
68+
69+
- name: "terraform-aws-multi-az-subnets"
70+
description: "Terraform module for multi-AZ public and private subnets provisioning"
71+
url: "https://github.com/cloudposse/terraform-aws-multi-az-subnets"
72+
73+
- name: "terraform-aws-named-subnets"
74+
description: "Terraform module for named subnets provisioning"
75+
url: "https://github.com/cloudposse/terraform-aws-named-subnets"
76+
77+
78+
# Short description of this project
79+
description: |-
80+
Terraform module to provision a [site-to-site](https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html) [VPN connection](https://docs.aws.amazon.com/vpc/latest/userguide/vpn-connections.html)
81+
between a VPC and an on-premises network.
82+
83+
The module does the following:
84+
85+
- Creates a Virtual Private Gateway (VPG) and attaches it to the VPC
86+
- Creates a Customer Gateway (CGW) pointing to the provided IP address of the Internet-routable external interface on the on-premises network
87+
- Creates a Site-to-Site Virtual Private Network (VPN) connection and assigns it to the VPG and CGW
88+
- Requests automatic route propagation between the VPG and the provided route tables in the VPC
89+
- If the VPN connection is configured to use static routes, provisions a static route between the VPN connection and the CGW
90+
91+
# How to use this project
92+
usage: |-
93+
```hcl
94+
module "vpn_connection" {
95+
source = "git::https://github.com/cloudposse/terraform-aws-vpn-connection.git?ref=master"
96+
namespace = "eg"
97+
stage = "dev"
98+
name = "test"
99+
vpc_id = "vpc-xxxxxxxx"
100+
vpn_gateway_amazon_side_asn = 64512
101+
customer_gateway_bgp_asn = 65000
102+
customer_gateway_ip_address = "172.0.0.1"
103+
route_table_ids = ["rtb-xxxxxxxx", "rtb-yyyyyyyy", "rtb-zzzzzzzz"]
104+
vpn_connection_static_routes_only = "true"
105+
vpn_connection_static_routes_destinations = ["10.80.1.0/24"]
106+
}
107+
```
108+
109+
include:
110+
- "docs/targets.md"
111+
- "docs/terraform.md"
112+
113+
# Contributors to this project
114+
contributors:
115+
- name: "Erik Osterman"
116+
github: "osterman"
117+
- name: "Andriy Knysh"
118+
github: "aknysh"
119+
- name: "Igor Rodionov"
120+
github: "goruha"
121+
- name: "Josh Myers"
122+
github: "joshmyers"

docs/targets.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Makefile Targets
2+
```
3+
Available targets:
4+
5+
help Help screen
6+
help/all Display help for all targets
7+
help/short This help short screen
8+
lint Lint terraform code
9+
10+
```

docs/terraform.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Inputs
2+
3+
| Name | Description | Type | Default | Required |
4+
|------|-------------|:----:|:-----:|:-----:|
5+
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
6+
| customer_gateway_bgp_asn | The gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN) | string | `65000` | no |
7+
| customer_gateway_ip_address | The IP address of the gateway's Internet-routable external interface | string | - | yes |
8+
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
9+
| enabled | Set to `false` to prevent the module from creating any resources | string | `true` | no |
10+
| name | Name (e.g. `app`) | string | - | yes |
11+
| namespace | Namespace (e.g. `eg` or `cp`) | string | - | yes |
12+
| route_table_ids | The IDs of the route tables for which routes from the Virtual Private Gateway will be propagated | list | `<list>` | no |
13+
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes |
14+
| tags | Additional tags (e.g. `{ BusinessUnit = "XYZ" }` | map | `<map>` | no |
15+
| vpc_id | The ID of the VPC to which the Virtual Private Gateway will be attached | string | - | yes |
16+
| vpn_connection_static_routes_destinations | List of CIDR blocks to be used as destination for static routes. Routes to destinations will be propagated to the route tables defined in `route_table_ids` | list | `<list>` | no |
17+
| vpn_connection_static_routes_only | If set to `true`, the VPN connection will use static routes exclusively. Static routes must be used for devices that don't support BGP | string | `true` | no |
18+
| vpn_connection_tunnel1_inside_cidr | The CIDR block of the inside IP addresses for the first VPN tunnel | string | `` | no |
19+
| vpn_connection_tunnel1_preshared_key | The preshared key of the first VPN tunnel. The preshared key must be between 8 and 64 characters in length and cannot start with zero. Allowed characters are alphanumeric characters, periods(.) and underscores(_) | string | `` | no |
20+
| vpn_connection_tunnel2_inside_cidr | The CIDR block of the inside IP addresses for the second VPN tunnel | string | `` | no |
21+
| vpn_connection_tunnel2_preshared_key | The preshared key of the second VPN tunnel. The preshared key must be between 8 and 64 characters in length and cannot start with zero. Allowed characters are alphanumeric characters, periods(.) and underscores(_) | string | `` | no |
22+
| vpn_gateway_amazon_side_asn | The Autonomous System Number (ASN) for the Amazon side of the VPN gateway. If you don't specify an ASN, the Virtual Private Gateway is created with the default ASN | string | `64512` | no |
23+
24+
## Outputs
25+
26+
| Name | Description |
27+
|------|-------------|
28+
| customer_gateway_id | Customer Gateway ID |
29+
| vpn_connection_customer_gateway_configuration | The configuration information for the VPN connection's Customer Gateway (in the native XML format) |
30+
| vpn_connection_id | VPN Connection ID |
31+
| vpn_connection_tunnel1_address | The public IP address of the first VPN tunnel |
32+
| vpn_connection_tunnel1_cgw_inside_address | The RFC 6890 link-local address of the first VPN tunnel (Customer Gateway side) |
33+
| vpn_connection_tunnel1_vgw_inside_address | The RFC 6890 link-local address of the first VPN tunnel (Virtual Private Gateway side) |
34+
| vpn_connection_tunnel2_address | The public IP address of the second VPN tunnel |
35+
| vpn_connection_tunnel2_cgw_inside_address | The RFC 6890 link-local address of the second VPN tunnel (Customer Gateway side) |
36+
| vpn_connection_tunnel2_vgw_inside_address | The RFC 6890 link-local address of the second VPN tunnel (Virtual Private Gateway side) |
37+
| vpn_gateway_id | Virtual Private Gateway ID |
38+

examples/complete/main.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
provider "aws" {
2+
region = "${var.region}"
3+
}
4+
5+
module "vpn_connection" {
6+
source = "../../"
7+
enabled = "${var.enabled}"
8+
namespace = "${var.namespace}"
9+
stage = "${var.stage}"
10+
name = "${var.name}"
11+
delimiter = "${var.delimiter}"
12+
attributes = "${var.attributes}"
13+
tags = "${var.tags}"
14+
vpc_id = "${var.vpc_id}"
15+
vpn_gateway_amazon_side_asn = "${var.vpn_gateway_amazon_side_asn}"
16+
customer_gateway_bgp_asn = "${var.customer_gateway_bgp_asn}"
17+
customer_gateway_ip_address = "${var.customer_gateway_ip_address}"
18+
route_table_ids = ["${var.route_table_ids}"]
19+
vpn_connection_static_routes_only = "${var.vpn_connection_static_routes_only}"
20+
vpn_connection_static_routes_destinations = "${var.vpn_connection_static_routes_destinations}"
21+
vpn_connection_tunnel1_inside_cidr = "${var.vpn_connection_tunnel1_inside_cidr}"
22+
vpn_connection_tunnel2_inside_cidr = "${var.vpn_connection_tunnel2_inside_cidr}"
23+
vpn_connection_tunnel1_preshared_key = "${var.vpn_connection_tunnel1_preshared_key}"
24+
vpn_connection_tunnel2_preshared_key = "${var.vpn_connection_tunnel2_preshared_key}"
25+
}

examples/complete/outputs.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
output "vpn_gateway_id" {
2+
description = "Virtual Private Gateway ID"
3+
value = "${module.vpn_connection.vpn_connection_id}"
4+
}
5+
6+
output "customer_gateway_id" {
7+
description = "Customer Gateway ID"
8+
value = "${module.vpn_connection.customer_gateway_id}"
9+
}
10+
11+
output "vpn_connection_id" {
12+
description = "VPN Connection ID"
13+
value = "${module.vpn_connection.vpn_connection_id}"
14+
}
15+
16+
output "vpn_connection_customer_gateway_configuration" {
17+
description = "The configuration information for the VPN connection's Customer Gateway (in the native XML format)"
18+
value = "${module.vpn_connection.vpn_connection_customer_gateway_configuration}"
19+
}
20+
21+
output "vpn_connection_tunnel1_address" {
22+
description = "The public IP address of the first VPN tunnel"
23+
value = "${module.vpn_connection.vpn_connection_tunnel1_address}"
24+
}
25+
26+
output "vpn_connection_tunnel1_cgw_inside_address" {
27+
description = "The RFC 6890 link-local address of the first VPN tunnel (Customer Gateway side)"
28+
value = "${module.vpn_connection.vpn_connection_tunnel1_cgw_inside_address}"
29+
}
30+
31+
output "vpn_connection_tunnel1_vgw_inside_address" {
32+
description = "The RFC 6890 link-local address of the first VPN tunnel (Virtual Private Gateway side)"
33+
value = "${module.vpn_connection.vpn_connection_tunnel1_vgw_inside_address}"
34+
}
35+
36+
output "vpn_connection_tunnel2_address" {
37+
description = "The public IP address of the second VPN tunnel"
38+
value = "${module.vpn_connection.vpn_connection_tunnel2_address}"
39+
}
40+
41+
output "vpn_connection_tunnel2_cgw_inside_address" {
42+
description = "The RFC 6890 link-local address of the second VPN tunnel (Customer Gateway side)"
43+
value = "${module.vpn_connection.vpn_connection_tunnel2_cgw_inside_address}"
44+
}
45+
46+
output "vpn_connection_tunnel2_vgw_inside_address" {
47+
description = "The RFC 6890 link-local address of the second VPN tunnel (Virtual Private Gateway side)"
48+
value = "${module.vpn_connection.vpn_connection_tunnel2_vgw_inside_address}"
49+
}

0 commit comments

Comments
 (0)