Skip to content

Commit

Permalink
Add the option to provide extra tags for NAT gateways (#20)
Browse files Browse the repository at this point in the history
iuriaranda authored Sep 19, 2018
1 parent cff9433 commit 66afc50
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ Creates a nat gateway and automatically adds a route table to the route tables p
* [`private_route_tables`]: List(required): List of private route tables that require the nat gateway [NOTE the number of nat gateways should match the number of private routes]
* [`number_nat_gateways`]: String(optional): Number of nat gateways required
* [`public_subnets`]: List(required): The subnets where we are going to create/deploy the NAT gateways
* [`tags`]: Map(optional): optional tags

### Output

4 changes: 1 addition & 3 deletions nat_gateway/main.tf
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@ resource "aws_nat_gateway" "gateway" {
allocation_id = "${aws_eip.nat_gateway.*.id[count.index]}"
subnet_id = "${var.public_subnets[count.index]}"

tags {
Name = "${data.aws_subnet.ngw_subnets.*.availability_zone[count.index]}"
}
tags = "${merge(var.tags, map("Name", data.aws_subnet.ngw_subnets.*.availability_zone[count.index]))}"
}

resource "aws_route" "r" {
6 changes: 6 additions & 0 deletions nat_gateway/variables.tf
Original file line number Diff line number Diff line change
@@ -7,3 +7,9 @@ variable "number_nat_gateways" {
variable "public_subnets" {
type = "list"
}

variable "tags" {
type = "map"
description = "Optional extra tags"
default = {}
}

0 comments on commit 66afc50

Please sign in to comment.