diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index d5886a6..1995474 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
- rev: v1.77.0
+ rev: v1.83.6
hooks:
- id: terraform_fmt
- id: terraform_validate
@@ -23,7 +23,7 @@ repos:
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
diff --git a/README.md b/README.md
index a33b6f3..3cf845d 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| [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 |
+| [create\_tgw\_routes](#input\_create\_tgw\_routes) | Controls if TGW Route Table / Routes should be created | `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 |
| [enable\_default\_route\_table\_association](#input\_enable\_default\_route\_table\_association) | Whether resource attachments are automatically associated with the default association route table | `bool` | `true` | no |
@@ -125,7 +126,6 @@ No modules.
| [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 |
-| [create\_tgw\_routes](#input\_create\_tgw\_routes) | Controls if TGW Route Table / Routes should be created | `bool` | `true` | 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 b11a040..4daec66 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13.1 |
+| [terraform](#requirement\_terraform) | >= 1.0 |
| [aws](#requirement\_aws) | >= 4.4 |
## Providers
@@ -31,8 +31,8 @@ No providers.
| Name | Source | Version |
|------|--------|---------|
| [tgw](#module\_tgw) | ../../ | n/a |
-| [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 3.0 |
-| [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 3.0 |
+| [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 5.0 |
+| [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 5.0 |
## Resources
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index a3be95f..4c5566d 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -83,7 +83,7 @@ module "tgw" {
module "vpc1" {
source = "terraform-aws-modules/vpc/aws"
- version = "~> 3.0"
+ version = "~> 5.0"
name = "${local.name}-vpc1"
cidr = "10.10.0.0/16"
@@ -100,7 +100,7 @@ module "vpc1" {
module "vpc2" {
source = "terraform-aws-modules/vpc/aws"
- version = "~> 3.0"
+ version = "~> 5.0"
name = "${local.name}-vpc2"
cidr = "10.20.0.0/16"
diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf
index 03533eb..46b7087 100644
--- a/examples/complete/versions.tf
+++ b/examples/complete/versions.tf
@@ -1,5 +1,5 @@
terraform {
- required_version = ">= 0.13.1"
+ required_version = ">= 1.0"
required_providers {
aws = {
diff --git a/examples/multi-account/README.md b/examples/multi-account/README.md
index a6b439d..7c5db64 100644
--- a/examples/multi-account/README.md
+++ b/examples/multi-account/README.md
@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13.1 |
+| [terraform](#requirement\_terraform) | >= 1.0 |
| [aws](#requirement\_aws) | >= 4.4 |
## Providers
@@ -32,8 +32,8 @@ No providers.
|------|--------|---------|
| [tgw](#module\_tgw) | ../../ | n/a |
| [tgw\_peer](#module\_tgw\_peer) | ../../ | n/a |
-| [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 3.0 |
-| [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 3.0 |
+| [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 5.0 |
+| [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 5.0 |
## Resources
diff --git a/examples/multi-account/main.tf b/examples/multi-account/main.tf
index 54dbcb2..56e0b70 100644
--- a/examples/multi-account/main.tf
+++ b/examples/multi-account/main.tf
@@ -104,6 +104,9 @@ module "tgw_peer" {
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
+ vpc_route_table_ids = module.vpc1.private_route_table_ids
+ tgw_destination_cidr = "0.0.0.0/0"
+
tgw_routes = [
{
destination_cidr_block = "30.0.0.0/16"
@@ -128,7 +131,7 @@ module "tgw_peer" {
module "vpc1" {
source = "terraform-aws-modules/vpc/aws"
- version = "~> 3.0"
+ version = "~> 5.0"
name = "${local.name}-vpc1"
cidr = "10.10.0.0/16"
@@ -146,7 +149,7 @@ module "vpc1" {
module "vpc2" {
source = "terraform-aws-modules/vpc/aws"
- version = "~> 3.0"
+ version = "~> 5.0"
providers = {
aws = aws.peer
diff --git a/examples/multi-account/versions.tf b/examples/multi-account/versions.tf
index 03533eb..46b7087 100644
--- a/examples/multi-account/versions.tf
+++ b/examples/multi-account/versions.tf
@@ -1,5 +1,5 @@
terraform {
- required_version = ">= 0.13.1"
+ required_version = ">= 1.0"
required_providers {
aws = {
diff --git a/main.tf b/main.tf
index e7b833b..744cd43 100644
--- a/main.tf
+++ b/main.tf
@@ -15,6 +15,7 @@ locals {
for rtb_id in try(v.vpc_route_table_ids, []) : {
rtb_id = rtb_id
cidr = v.tgw_destination_cidr
+ tgw_id = var.create_tgw ? aws_ec2_transit_gateway.this[0].id : v.tgw_id
}
]
])
@@ -110,11 +111,14 @@ resource "aws_ec2_transit_gateway_route" "this" {
}
resource "aws_route" "this" {
- for_each = { for x in local.vpc_route_table_destination_cidr : x.rtb_id => x.cidr }
+ for_each = { for x in local.vpc_route_table_destination_cidr : x.rtb_id => {
+ cidr = x.cidr,
+ tgw_id = x.tgw_id
+ } }
route_table_id = each.key
- destination_cidr_block = each.value
- transit_gateway_id = aws_ec2_transit_gateway.this[0].id
+ destination_cidr_block = each.value["cidr"]
+ transit_gateway_id = each.value["tgw_id"]
}
resource "aws_ec2_transit_gateway_route_table_association" "this" {