diff --git a/README.md b/README.md index 84c23e8..fe16f6f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,69 @@ # tf-aws-vpn-gateway Terraform AWS VPN Gateway Module + +## Summary +This terraform module creates an AWS VPN Gateway and Connection to an existing AWS Customer Gateway. +- An AWS Customer Gateway must be provisioned separately. +- Learn More about [AWS VPN Connections](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_VPN.html) + +## Example Implementation + + /project # Terraform Project + /workspaces # Workspaces + /ops # Operations Environment + vpn_gateway. # VPN Gateway Stack using Module + backend.tf + data.tf + main.tf + providers.tf + /dev # Development Environment + /tst # Testing Environment + /stg # Staging Environment + /prd # Production Environment + +### backend.tf + + terraform { + backend "s3" { + bucket = "" + key = "vpn_gateway_" + workspace_key_prefix = "terraform" + region = "us-east-1" + profile = "" + role_arn = "arn:aws:iam:::role/" + +### data.tf + + data "terraform_remote_state" "network" { + backend = "s3" + workspace = "${terraform.workspace}" + + config { + bucket = "" + key = "network" + workspace_key_prefix = "terraform" + region = "us-east-1" + profile = "" + role_arn = "arn:aws:iam:::role/" + } + } + +### main.tf + + module "vpn_gateway" { + source = "git::ssh://git@github.com/gadgetry-io/tf-aws-vpn-gateway.git?ref=master" + vgw_vpc_id = "" + vgw_availability_zone = "" + vgw_tag_name = "" + vgw_tag_environment = "" + vgw_tag_stack = "" + vpn_destination_cidr_block = "" + vpn_customer_gateway_id = " + } + +### providers.tf + + provider aws { + region = "us-east-1" + profile = "" + } \ No newline at end of file diff --git a/aws_vpn_connection.tf b/aws_vpn_connection.tf new file mode 100644 index 0000000..9da257d --- /dev/null +++ b/aws_vpn_connection.tf @@ -0,0 +1,6 @@ +resource "aws_vpn_connection" "main" { + vpn_gateway_id = "${aws_vpn_gateway.main.id}" + customer_gateway_id = "${var.vpn_customer_gateway_id}" + type = "ipsec.1" + static_routes_only = true +} \ No newline at end of file diff --git a/aws_vpn_connection_route.tf b/aws_vpn_connection_route.tf new file mode 100644 index 0000000..038baab --- /dev/null +++ b/aws_vpn_connection_route.tf @@ -0,0 +1,4 @@ +resource "aws_vpn_connection_route" "main" { + destination_cidr_block = "${var.vpn_destination_cidr_block}" + vpn_connection_id = "${aws_vpn_connection.main.id}" +} \ No newline at end of file diff --git a/aws_vpn_gateway.tf b/aws_vpn_gateway.tf new file mode 100644 index 0000000..c440263 --- /dev/null +++ b/aws_vpn_gateway.tf @@ -0,0 +1,10 @@ +resource "aws_vpn_gateway" "main" { + vpc_id = "${var.vgw_vpc_id}" + availability_zone = "{var.vgw_availability_zone}" + + tags { + Name = "${var.vgw_tag_name}" + Environment = "${var.vgw_tag_environment}" + Stack = "${var.vgw_tag_stack}" + } +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..1c0792a --- /dev/null +++ b/outputs.tf @@ -0,0 +1,57 @@ +############################################################################### +# VPN Gateway Outputs + +output "vgw_id" { + value = "${aws_vpn_gateway.main.id}" +} + +############################################################################### +# VPN Connection Outputs. + +output "vpn_id" { + value = "${aws_vpn_connection.main.id}" +} + +output "vpn_type" { + value = "${aws_vpn_connection.main.type}" +} + +output "vpn_customer_gateway_id" { + value = "${aws_vpn_connection.main.customer_gateway_id}" +} + +output "vpn_static_routes_only" { + value = "${aws_vpn_connection.main.static_routes_only}" +} + +output "vpn_tunnel1_address" { + value = "${aws_vpn_connection.main.tunnel1_address}" +} + +output "vpn_tunnel1_bgp_asn" { + value = "${aws_vpn_connection.main.tunnel1_bgp_asn}" +} + +output "vpn_tunnel1_cgw_inside_address" { + value = "${aws_vpn_connection.main.tunnel1_cgw_inside_address}" +} + +output "vpn_tunnel1_vgw_inside_address" { + value = "${aws_vpn_connection.main.tunnel1_vgw_inside_address}" +} + +output "vpn_tunnel2_address" { + value = "${aws_vpn_connection.main.tunnel2_address}" +} + +output "vpn_tunnel2_bgp_asn" { + value = "${aws_vpn_connection.main.tunnel2_bgp_asn}" +} + +output "vpn_tunnel2_cgw_inside_address" { + value = "${aws_vpn_connection.main.tunnel2_cgw_inside_address}" +} + +output "vpn_tunnel2_vgw_inside_address" { + value = "${aws_vpn_connection.main.tunnel2_vgw_inside_address}" +} \ No newline at end of file diff --git a/readme.tf b/readme.tf new file mode 100644 index 0000000..9dda997 --- /dev/null +++ b/readme.tf @@ -0,0 +1,53 @@ +resource "local_file" "readme" { + content = "${data.template_file.readme.rendered}" + filename = "${path.module}/README.${upper(terraform.workspace)}.md" +} + +data "template_file" "readme" { + template = <