Created
January 21, 2018 12:07
-
-
Save 328/b345b3d43032f27fe0131c037bf4a150 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "stage" {} | |
variable "access_key" {} | |
variable "secret_key" {} | |
variable "region" {} | |
provider "aws" { | |
access_key = "${var.access_key}" | |
secret_key = "${var.secret_key}" | |
region = "${var.region}" | |
} | |
resource "aws_vpc" "328-vpc" { | |
cidr_block = "10.0.0.0/16" | |
instance_tenancy = "default" | |
enable_dns_support = true | |
enable_dns_hostnames = true | |
tags { | |
Name = "328-vpc" | |
} | |
} | |
resource "aws_subnet" "328-external" { | |
vpc_id = "${aws_vpc.328-vpc.id}" | |
cidr_block = "10.0.10.0/24" | |
tags { | |
Name = "328-external" | |
} | |
} | |
## route table | |
resource "aws_internet_gateway" "328-internet-gw" { | |
vpc_id = "${aws_vpc.328-vpc.id}" | |
tags { | |
Name = "328-vpc" | |
} | |
} | |
## public route table | |
resource "aws_route_table" "328-public" { | |
vpc_id = "${aws_vpc.328-vpc.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "${aws_internet_gateway.328-internet-gw.id}" | |
} | |
} | |
resource "aws_route_table_association" "328-external" { | |
subnet_id = "${aws_subnet.328-external.id}" | |
route_table_id = "${aws_route_table.328-public.id}" | |
} | |
resource "aws_main_route_table_association" "328-external" { | |
vpc_id = "${aws_vpc.328-vpc.id}" | |
route_table_id = "${aws_route_table.328-public.id}" | |
} | |
resource "aws_vpn_gateway" "328-vpn-gw" { | |
vpc_id = "${aws_vpc.328-vpc.id}" | |
tags { | |
Name = "328vpngateway" | |
} | |
} | |
resource "aws_customer_gateway" "328vpngateway" { | |
bgp_asn = 65000 | |
ip_address = "xxx.xxx.xxx.xxx" | |
type = "ipsec.1" | |
tags { | |
Name = "328VpnGateway" | |
} | |
} | |
resource "aws_vpn_connection" "328vpn" { | |
vpn_gateway_id = "${aws_vpn_gateway.328-vpn-gw.id}" | |
customer_gateway_id = "${aws_customer_gateway.328vpngateway.id}" | |
type = "ipsec.1" | |
static_routes_only = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment