From 4394b256cc0f72eaa63a08f0101cbf129afc5b6f Mon Sep 17 00:00:00 2001 From: Lays Rodrigues Date: Thu, 17 Dec 2020 10:13:37 -0300 Subject: [PATCH] feat: Add support to tag default route table Signed-off-by: Lays Rodrigues --- README.md | 1 + main.tf | 16 ++++++++++++++++ variables.tf | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 5c1a72efa..5304ea2aa 100644 --- a/README.md +++ b/README.md @@ -331,6 +331,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway | default\_network\_acl\_ingress | List of maps of ingress rules to set on the Default Network ACL | `list(map(string))` |
[
{
"action": "allow",
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_no": 100,
"to_port": 0
},
{
"action": "allow",
"from_port": 0,
"ipv6_cidr_block": "::/0",
"protocol": "-1",
"rule_no": 101,
"to_port": 0
}
]
| no | | default\_network\_acl\_name | Name to be used on the Default Network ACL | `string` | `""` | no | | default\_network\_acl\_tags | Additional tags for the Default Network ACL | `map(string)` | `{}` | no | +| default\_route\_table\_tags | Additional tags for the Default Route Table | `map(string)` | `{}` | no | | default\_security\_group\_egress | List of maps of egress rules to set on the default security group | `list(map(string))` | `null` | no | | default\_security\_group\_ingress | List of maps of ingress rules to set on the default security group | `list(map(string))` | `null` | no | | default\_security\_group\_name | Name to be used on the default security group | `string` | `"default"` | no | diff --git a/main.tf b/main.tf index e83ad6137..5d241c381 100644 --- a/main.tf +++ b/main.tf @@ -160,6 +160,22 @@ resource "aws_egress_only_internet_gateway" "this" { ) } + +################ +# Default route +################ +resource "aws_default_route_table" "default" { + count = var.create_vpc ? 1 : 0 + default_route_table_id = aws_vpc.this[0].default_route_table_id + tags = merge( + { + "Name" = format("%s", var.name) + }, + var.tags, + var.default_route_table_tags, + ) +} + ################ # Publiс routes ################ diff --git a/variables.tf b/variables.tf index 223697301..a14d2b7ab 100644 --- a/variables.tf +++ b/variables.tf @@ -2596,3 +2596,9 @@ variable "create_egress_only_igw" { type = bool default = true } + +variable "default_route_table_tags" { + description = "Additional tags for the Default Route Table" + type = map(string) + default = {} +}