Skip to content

Commit

Permalink
Merge pull request #80 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 8.3.0 - new variable `create_nat_gateway`
  • Loading branch information
briskt authored Jun 12, 2023
2 parents 2594df2 + 9f1889e commit c12b09c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions aws/vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ be useful.
## Optional Inputs

- `enable_dns_hostnames` - default `false`
- `create_nat_gateway` - default `true`

## Outputs

Expand Down
6 changes: 5 additions & 1 deletion aws/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ resource "aws_eip" "gateway_eip" {
}

resource "aws_nat_gateway" "nat_gateway" {
count = var.create_nat_gateway ? 1 : 0

allocation_id = aws_eip.gateway_eip.id
subnet_id = aws_subnet.public_subnet[0].id
depends_on = [aws_internet_gateway.internet_gateway]
Expand All @@ -100,9 +102,11 @@ resource "aws_route_table" "nat_route_table" {
}

resource "aws_route" "nat_route" {
count = var.create_nat_gateway ? 1 : 0

route_table_id = aws_route_table.nat_route_table.id
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.nat_gateway.id
nat_gateway_id = one(aws_nat_gateway.nat_gateway[*].id)
}

resource "aws_route_table_association" "private_route" {
Expand Down
2 changes: 1 addition & 1 deletion aws/vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ output "aws_zones" {
}

output "nat_gateway_ip" {
value = aws_nat_gateway.nat_gateway.public_ip
value = one(aws_nat_gateway.nat_gateway[*].public_ip)
}

5 changes: 5 additions & 0 deletions aws/vpc/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ variable "enable_dns_hostnames" {
default = false
}

variable "create_nat_gateway" {
description = "Set to false to remove NAT gateway and associated route"
type = bool
default = true
}

0 comments on commit c12b09c

Please sign in to comment.