Skip to content

Commit 9bc4844

Browse files
bcenkerantonbabenko
authored andcommitted
1 parent 1cdd000 commit 9bc4844

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ These types of resources are supported:
1111
* [Route table](https://www.terraform.io/docs/providers/aws/r/route_table.html)
1212
* [Internet Gateway](https://www.terraform.io/docs/providers/aws/r/internet_gateway.html)
1313
* [NAT Gateway](https://www.terraform.io/docs/providers/aws/r/nat_gateway.html)
14+
* [VPN Gateway](https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html)
1415
* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html) (S3 and DynamoDB)
1516
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
1617
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
@@ -30,6 +31,7 @@ module "vpc" {
3031
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
3132
3233
enable_nat_gateway = true
34+
enable_vpn_gateway = true
3335
3436
tags = {
3537
Terraform = "true"

examples/complete-vpc/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module "vpc" {
1414
create_database_subnet_group = false
1515

1616
enable_nat_gateway = true
17+
enable_vpn_gateway = true
1718

1819
enable_s3_endpoint = true
1920
enable_dynamodb_endpoint = true

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,14 @@ resource "aws_route_table_association" "public" {
242242
subnet_id = "${element(aws_subnet.public.*.id, count.index)}"
243243
route_table_id = "${aws_route_table.public.id}"
244244
}
245+
246+
##############
247+
# VPN Gateway
248+
##############
249+
resource "aws_vpn_gateway" "this" {
250+
count = "${var.enable_vpn_gateway ? 1 : 0}"
251+
252+
vpc_id = "${aws_vpc.this.id}"
253+
254+
tags = "${merge(var.tags, map("Name", format("%s", var.name)))}"
255+
}

outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,9 @@ output "vpc_endpoint_dynamodb_id" {
112112
description = "The ID of VPC endpoint for DynamoDB"
113113
value = "${aws_vpc_endpoint.dynamodb.id}"
114114
}
115+
116+
# VPN Gateway
117+
output "vgw_id" {
118+
description = "The ID of the VPN Gateway"
119+
value = "${aws_vpn_gateway.this.id}"
120+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ variable "map_public_ip_on_launch" {
8080
default = true
8181
}
8282

83+
variable "enable_vpn_gateway" {
84+
description = "Should be true if you want to create a new VPN Gateway resource and attach it to the VPC"
85+
default = false
86+
}
87+
8388
variable "private_propagating_vgws" {
8489
description = "A list of VGWs the private route table should propagate"
8590
default = []

0 commit comments

Comments
 (0)