Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.1
rev: v1.100.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand All @@ -23,7 +23,7 @@ repos:
- '--args=--only=terraform_workspace_remote'
- id: terraform_validate
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
Expand Down
37 changes: 11 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Terraform module which creates Transit Gateway resources on AWS.
```hcl
module "tgw" {
source = "terraform-aws-modules/transit-gateway/aws"
version = "~> 2.0"

name = "my-tgw"
description = "My TGW shared with several other AWS accounts"
Expand All @@ -16,8 +15,8 @@ module "tgw" {

vpc_attachments = {
vpc = {
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
vpc_id = "vpc-1234556abcdef"
subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
dns_support = true
ipv6_support = true

Expand All @@ -26,36 +25,21 @@ module "tgw" {
destination_cidr_block = "30.0.0.0/16"
},
{
blackhole = true
blackhole = true
destination_cidr_block = "40.0.0.0/20"
}
]
}
}

ram_allow_external_principals = true
ram_principals = [307990089504]
ram_principals = [307990089504]

tags = {
Purpose = "tgw-complete-example"
Terraform = "true"
Environment = "dev"
}
}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"

name = "my-vpc"

cidr = "10.10.0.0/16"

azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
private_subnets = ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"]

enable_ipv6 = true
private_subnet_assign_ipv6_address_on_creation = true
private_subnet_ipv6_prefixes = [0, 1, 2]
}
```

## Examples
Expand All @@ -68,14 +52,14 @@ module "vpc" {

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.4 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.4 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |

## Modules

Expand Down Expand Up @@ -119,13 +103,14 @@ No modules.
| <a name="input_ram_principals"></a> [ram\_principals](#input\_ram\_principals) | A list of principals to share TGW with. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN | `list(string)` | `[]` | no |
| <a name="input_ram_resource_share_arn"></a> [ram\_resource\_share\_arn](#input\_ram\_resource\_share\_arn) | ARN of RAM resource share | `string` | `""` | no |
| <a name="input_ram_tags"></a> [ram\_tags](#input\_ram\_tags) | Additional tags for the RAM | `map(string)` | `{}` | no |
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |
| <a name="input_share_tgw"></a> [share\_tgw](#input\_share\_tgw) | Whether to share your transit gateway with other accounts | `bool` | `true` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
| <a name="input_tgw_default_route_table_tags"></a> [tgw\_default\_route\_table\_tags](#input\_tgw\_default\_route\_table\_tags) | Additional tags for the Default TGW route table | `map(string)` | `{}` | no |
| <a name="input_tgw_route_table_tags"></a> [tgw\_route\_table\_tags](#input\_tgw\_route\_table\_tags) | Additional tags for the TGW route table | `map(string)` | `{}` | no |
| <a name="input_tgw_tags"></a> [tgw\_tags](#input\_tgw\_tags) | Additional tags for the TGW | `map(string)` | `{}` | no |
| <a name="input_tgw_vpc_attachment_tags"></a> [tgw\_vpc\_attachment\_tags](#input\_tgw\_vpc\_attachment\_tags) | Additional tags for VPC attachments | `map(string)` | `{}` | no |
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the transit gateway | `map(string)` | `{}` | no |
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the transit gateway | <pre>object({<br/> create = optional(bool)<br/> update = optional(bool)<br/> delete = optional(bool)<br/> })</pre> | `null` | no |
| <a name="input_transit_gateway_cidr_blocks"></a> [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 |
| <a name="input_transit_gateway_route_table_id"></a> [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 |
| <a name="input_vpc_attachments"></a> [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 |
Expand Down
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Examples

The examples provided demonstrate different cluster configurations that users can create with the modules provided.

Please do not mistake the examples provided as "best practices". It is up to users to consult the AWS service documentation for best practices, usage recommendations, etc.
16 changes: 10 additions & 6 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,28 @@ Note that this example may create resources which cost money. Run `terraform des

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.4 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_tgw"></a> [tgw](#module\_tgw) | ../../ | n/a |
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 5.0 |
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 5.0 |
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 6.0 |
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 6.0 |

## Resources

No resources.
| Name | Type |
|------|------|
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |

## Inputs

Expand Down
32 changes: 19 additions & 13 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ provider "aws" {
region = local.region
}

data "aws_availability_zones" "available" {}

locals {
name = "ex-tgw-${replace(basename(path.cwd), "_", "-")}"
region = "eu-west-1"
name = "ex-${basename(path.cwd)}"

vpc1_cidr = "10.10.0.0/16"
vpc2_cidr = "10.20.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Name = local.name
Example = local.name
GithubRepo = "terraform-aws-eks"
GithubOrg = "terraform-aws-transit-gateway"
Repository = "https://github.com/terraform-aws-modules/terraform-aws-transit-gateway"
}
}

Expand Down Expand Up @@ -87,13 +93,13 @@ module "tgw" {

module "vpc1" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
version = "~> 6.0"

name = "${local.name}-vpc1"
cidr = "10.10.0.0/16"
name = "${local.name}-1"
cidr = local.vpc1_cidr

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"]
azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc1_cidr, 8, k)]

enable_ipv6 = true
private_subnet_assign_ipv6_address_on_creation = true
Expand All @@ -104,13 +110,13 @@ module "vpc1" {

module "vpc2" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
version = "~> 6.0"

name = "${local.name}-vpc2"
cidr = "10.20.0.0/16"
name = "${local.name}-2"
cidr = local.vpc2_cidr

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24"]
azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc2_cidr, 8, k)]

enable_ipv6 = false

Expand Down
4 changes: 2 additions & 2 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.0"
required_version = ">= 1.5.7"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.4"
version = ">= 6.0"
}
}
}
16 changes: 10 additions & 6 deletions examples/multi-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@ Note that this example may create resources which cost money. Run `terraform des

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.4 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_tgw"></a> [tgw](#module\_tgw) | ../../ | n/a |
| <a name="module_tgw_peer"></a> [tgw\_peer](#module\_tgw\_peer) | ../../ | n/a |
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 5.0 |
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 5.0 |
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 6.0 |
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 6.0 |

## Resources

No resources.
| Name | Type |
|------|------|
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |

## Inputs

Expand Down
37 changes: 19 additions & 18 deletions examples/multi-account/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ provider "aws" {
alias = "peer"
}

data "aws_availability_zones" "available" {}

locals {
name = "ex-tgw-${replace(basename(path.cwd), "_", "-")}"
region = "eu-west-1"
name = "ex-${basename(path.cwd)}"

vpc1_cidr = "10.10.0.0/16"
vpc2_cidr = "10.20.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Name = local.name
Example = local.name
GithubRepo = "terraform-aws-eks"
GithubOrg = "terraform-aws-transit-gateway"
Repository = "https://github.com/terraform-aws-modules/terraform-aws-transit-gateway"
}
}

Expand Down Expand Up @@ -131,13 +137,13 @@ module "tgw_peer" {

module "vpc1" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
version = "~> 6.0"

name = "${local.name}-vpc1"
cidr = "10.10.0.0/16"
name = "${local.name}-1"
cidr = local.vpc1_cidr

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"]
azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc1_cidr, 8, k)]

enable_ipv6 = true
private_subnet_assign_ipv6_address_on_creation = true
Expand All @@ -146,20 +152,15 @@ module "vpc1" {
tags = local.tags
}


module "vpc2" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"

providers = {
aws = aws.peer
}
version = "~> 6.0"

name = "${local.name}-vpc2"
cidr = "10.20.0.0/16"
name = "${local.name}-2"
cidr = local.vpc2_cidr

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24"]
azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc2_cidr, 8, k)]

enable_ipv6 = false

Expand Down
4 changes: 2 additions & 2 deletions examples/multi-account/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.0"
required_version = ">= 1.5.7"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.4"
version = ">= 6.0"
}
}
}
Loading