From 131ed5006713aec86a20147796ce6489f6daadc6 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Sat, 26 Mar 2022 16:23:56 -0400 Subject: [PATCH] feat: Add support for transit gateway CIDR blocks (#69) --- README.md | 8 +++++--- examples/complete/README.md | 2 +- examples/complete/main.tf | 2 ++ examples/complete/versions.tf | 2 +- examples/multi-account/README.md | 2 +- examples/multi-account/versions.tf | 2 +- main.tf | 7 +++++++ variables.tf | 14 +++++++++++++- versions.tf | 2 +- 9 files changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 48d0529..a80e0ae 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,13 @@ module "vpc" { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.15 | +| [aws](#requirement\_aws) | >= 4.4 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.15 | +| [aws](#provider\_aws) | >= 4.4 | ## Modules @@ -102,7 +102,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [amazon\_side\_asn](#input\_amazon\_side\_asn) | The Autonomous System Number (ASN) for the Amazon side of the gateway. By default the TGW is created with the current default Amazon ASN. | `string` | `"64512"` | no | +| [amazon\_side\_asn](#input\_amazon\_side\_asn) | The Autonomous System Number (ASN) for the Amazon side of the gateway. By default the TGW is created with the current default Amazon ASN. | `string` | `null` | no | | [create\_tgw](#input\_create\_tgw) | Controls if TGW should be created (it affects almost all resources) | `bool` | `true` | no | | [description](#input\_description) | Description of the EC2 Transit Gateway | `string` | `null` | no | | [enable\_auto\_accept\_shared\_attachments](#input\_enable\_auto\_accept\_shared\_attachments) | Whether resource attachment requests are automatically accepted | `bool` | `false` | no | @@ -122,6 +122,8 @@ No modules. | [tgw\_route\_table\_tags](#input\_tgw\_route\_table\_tags) | Additional tags for the TGW route table | `map(string)` | `{}` | no | | [tgw\_tags](#input\_tgw\_tags) | Additional tags for the TGW | `map(string)` | `{}` | no | | [tgw\_vpc\_attachment\_tags](#input\_tgw\_vpc\_attachment\_tags) | Additional tags for VPC attachments | `map(string)` | `{}` | no | +| [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the transit gateway | `map(string)` | `{}` | no | +| [transit\_gateway\_cidr\_blocks](#input\_transit\_gateway\_cidr\_blocks) | One or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6 | `list(string)` | `[]` | no | | [transit\_gateway\_route\_table\_id](#input\_transit\_gateway\_route\_table\_id) | Identifier of EC2 Transit Gateway Route Table to use with the Target Gateway when reusing it between multiple TGWs | `string` | `null` | no | | [vpc\_attachments](#input\_vpc\_attachments) | Maps of maps of VPC details to attach to TGW. Type 'any' to disable type validation by Terraform. | `any` | `{}` | no | diff --git a/examples/complete/README.md b/examples/complete/README.md index 128008c..b11a040 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -20,7 +20,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.15 | +| [aws](#requirement\_aws) | >= 4.4 | ## Providers diff --git a/examples/complete/main.tf b/examples/complete/main.tf index edd484b..db93651 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -24,6 +24,8 @@ module "tgw" { description = "My TGW shared with several other AWS accounts" amazon_side_asn = 64532 + transit_gateway_cidr_blocks = ["10.99.0.0/24"] + # When "true" there is no need for RAM resources if using multiple AWS accounts enable_auto_accept_shared_attachments = true diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 8519187..03533eb 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.15" + version = ">= 4.4" } } } diff --git a/examples/multi-account/README.md b/examples/multi-account/README.md index 6a1f126..a6b439d 100644 --- a/examples/multi-account/README.md +++ b/examples/multi-account/README.md @@ -20,7 +20,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.15 | +| [aws](#requirement\_aws) | >= 4.4 | ## Providers diff --git a/examples/multi-account/versions.tf b/examples/multi-account/versions.tf index 8519187..03533eb 100644 --- a/examples/multi-account/versions.tf +++ b/examples/multi-account/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.15" + version = ">= 4.4" } } } diff --git a/main.tf b/main.tf index a20a343..adab914 100644 --- a/main.tf +++ b/main.tf @@ -34,6 +34,13 @@ resource "aws_ec2_transit_gateway" "this" { auto_accept_shared_attachments = var.enable_auto_accept_shared_attachments ? "enable" : "disable" vpn_ecmp_support = var.enable_vpn_ecmp_support ? "enable" : "disable" dns_support = var.enable_dns_support ? "enable" : "disable" + transit_gateway_cidr_blocks = var.transit_gateway_cidr_blocks + + timeouts { + create = try(var.timeouts.create, null) + update = try(var.timeouts.update, null) + delete = try(var.timeouts.delete, null) + } tags = merge( var.tags, diff --git a/variables.tf b/variables.tf index 316ddbb..ec6ec96 100644 --- a/variables.tf +++ b/variables.tf @@ -29,7 +29,7 @@ variable "description" { variable "amazon_side_asn" { description = "The Autonomous System Number (ASN) for the Amazon side of the gateway. By default the TGW is created with the current default Amazon ASN." type = string - default = "64512" + default = null } variable "enable_default_route_table_association" { @@ -62,6 +62,18 @@ variable "enable_dns_support" { default = true } +variable "transit_gateway_cidr_blocks" { + description = "One or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6" + type = list(string) + default = [] +} + +variable "timeouts" { + description = "Create, update, and delete timeout configurations for the transit gateway" + type = map(string) + default = {} +} + variable "tgw_tags" { description = "Additional tags for the TGW" type = map(string) diff --git a/versions.tf b/versions.tf index 8519187..03533eb 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.15" + version = ">= 4.4" } } }