Skip to content

Commit 9ded85b

Browse files
mohagGert van den Bergtamskybryantbiggs
authored
feat!: Raise MSV of Terraform and AWS provider to v1.5.7 and v6.0.0 respectively, add support for region argument (#146)
Co-authored-by: Gert van den Berg <[email protected]> Co-authored-by: Marc Tamsky <[email protected]> Co-authored-by: Bryant Biggs <[email protected]>
1 parent b0e2730 commit 9ded85b

File tree

12 files changed

+131
-85
lines changed

12 files changed

+131
-85
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.96.1
3+
rev: v1.100.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs
@@ -23,7 +23,7 @@ repos:
2323
- '--args=--only=terraform_workspace_remote'
2424
- id: terraform_validate
2525
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v5.0.0
26+
rev: v6.0.0
2727
hooks:
2828
- id: check-merge-conflict
2929
- id: end-of-file-fixer

README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Terraform module which creates Transit Gateway resources on AWS.
77
```hcl
88
module "tgw" {
99
source = "terraform-aws-modules/transit-gateway/aws"
10-
version = "~> 2.0"
1110
1211
name = "my-tgw"
1312
description = "My TGW shared with several other AWS accounts"
@@ -16,8 +15,8 @@ module "tgw" {
1615
1716
vpc_attachments = {
1817
vpc = {
19-
vpc_id = module.vpc.vpc_id
20-
subnet_ids = module.vpc.private_subnets
18+
vpc_id = "vpc-1234556abcdef"
19+
subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
2120
dns_support = true
2221
ipv6_support = true
2322
@@ -26,36 +25,21 @@ module "tgw" {
2625
destination_cidr_block = "30.0.0.0/16"
2726
},
2827
{
29-
blackhole = true
28+
blackhole = true
3029
destination_cidr_block = "40.0.0.0/20"
3130
}
3231
]
3332
}
3433
}
3534
3635
ram_allow_external_principals = true
37-
ram_principals = [307990089504]
36+
ram_principals = [307990089504]
3837
3938
tags = {
40-
Purpose = "tgw-complete-example"
39+
Terraform = "true"
40+
Environment = "dev"
4141
}
4242
}
43-
44-
module "vpc" {
45-
source = "terraform-aws-modules/vpc/aws"
46-
version = "~> 3.0"
47-
48-
name = "my-vpc"
49-
50-
cidr = "10.10.0.0/16"
51-
52-
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
53-
private_subnets = ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"]
54-
55-
enable_ipv6 = true
56-
private_subnet_assign_ipv6_address_on_creation = true
57-
private_subnet_ipv6_prefixes = [0, 1, 2]
58-
}
5943
```
6044

6145
## Examples
@@ -68,14 +52,14 @@ module "vpc" {
6852

6953
| Name | Version |
7054
|------|---------|
71-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
72-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.4 |
55+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
56+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
7357

7458
## Providers
7559

7660
| Name | Version |
7761
|------|---------|
78-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.4 |
62+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
7963

8064
## Modules
8165

@@ -119,13 +103,14 @@ No modules.
119103
| <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 |
120104
| <a name="input_ram_resource_share_arn"></a> [ram\_resource\_share\_arn](#input\_ram\_resource\_share\_arn) | ARN of RAM resource share | `string` | `""` | no |
121105
| <a name="input_ram_tags"></a> [ram\_tags](#input\_ram\_tags) | Additional tags for the RAM | `map(string)` | `{}` | no |
106+
| <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 |
122107
| <a name="input_share_tgw"></a> [share\_tgw](#input\_share\_tgw) | Whether to share your transit gateway with other accounts | `bool` | `true` | no |
123108
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
124109
| <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 |
125110
| <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 |
126111
| <a name="input_tgw_tags"></a> [tgw\_tags](#input\_tgw\_tags) | Additional tags for the TGW | `map(string)` | `{}` | no |
127112
| <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 |
128-
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the transit gateway | `map(string)` | `{}` | no |
113+
| <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 |
129114
| <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 |
130115
| <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 |
131116
| <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 |

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Examples
2+
3+
The examples provided demonstrate different cluster configurations that users can create with the modules provided.
4+
5+
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.

examples/complete/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,28 @@ Note that this example may create resources which cost money. Run `terraform des
1919

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

2525
## Providers
2626

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

2931
## Modules
3032

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

3739
## Resources
3840

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

4145
## Inputs
4246

examples/complete/main.tf

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ provider "aws" {
22
region = local.region
33
}
44

5+
data "aws_availability_zones" "available" {}
6+
57
locals {
6-
name = "ex-tgw-${replace(basename(path.cwd), "_", "-")}"
78
region = "eu-west-1"
9+
name = "ex-${basename(path.cwd)}"
10+
11+
vpc1_cidr = "10.10.0.0/16"
12+
vpc2_cidr = "10.20.0.0/16"
13+
azs = slice(data.aws_availability_zones.available.names, 0, 3)
814

915
tags = {
16+
Name = local.name
1017
Example = local.name
11-
GithubRepo = "terraform-aws-eks"
12-
GithubOrg = "terraform-aws-transit-gateway"
18+
Repository = "https://github.com/terraform-aws-modules/terraform-aws-transit-gateway"
1319
}
1420
}
1521

@@ -87,13 +93,13 @@ module "tgw" {
8793

8894
module "vpc1" {
8995
source = "terraform-aws-modules/vpc/aws"
90-
version = "~> 5.0"
96+
version = "~> 6.0"
9197

92-
name = "${local.name}-vpc1"
93-
cidr = "10.10.0.0/16"
98+
name = "${local.name}-1"
99+
cidr = local.vpc1_cidr
94100

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

98104
enable_ipv6 = true
99105
private_subnet_assign_ipv6_address_on_creation = true
@@ -104,13 +110,13 @@ module "vpc1" {
104110

105111
module "vpc2" {
106112
source = "terraform-aws-modules/vpc/aws"
107-
version = "~> 5.0"
113+
version = "~> 6.0"
108114

109-
name = "${local.name}-vpc2"
110-
cidr = "10.20.0.0/16"
115+
name = "${local.name}-2"
116+
cidr = local.vpc2_cidr
111117

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

115121
enable_ipv6 = false
116122

examples/complete/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.0"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.4"
7+
version = ">= 6.0"
88
}
99
}
1010
}

examples/multi-account/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,29 @@ Note that this example may create resources which cost money. Run `terraform des
1919

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

2525
## Providers
2626

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

2931
## Modules
3032

3133
| Name | Source | Version |
3234
|------|--------|---------|
3335
| <a name="module_tgw"></a> [tgw](#module\_tgw) | ../../ | n/a |
3436
| <a name="module_tgw_peer"></a> [tgw\_peer](#module\_tgw\_peer) | ../../ | n/a |
35-
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 5.0 |
36-
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 5.0 |
37+
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | terraform-aws-modules/vpc/aws | ~> 6.0 |
38+
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | terraform-aws-modules/vpc/aws | ~> 6.0 |
3739

3840
## Resources
3941

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

4246
## Inputs
4347

examples/multi-account/main.tf

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ provider "aws" {
88
alias = "peer"
99
}
1010

11+
data "aws_availability_zones" "available" {}
12+
1113
locals {
12-
name = "ex-tgw-${replace(basename(path.cwd), "_", "-")}"
1314
region = "eu-west-1"
15+
name = "ex-${basename(path.cwd)}"
16+
17+
vpc1_cidr = "10.10.0.0/16"
18+
vpc2_cidr = "10.20.0.0/16"
19+
azs = slice(data.aws_availability_zones.available.names, 0, 3)
1420

1521
tags = {
22+
Name = local.name
1623
Example = local.name
17-
GithubRepo = "terraform-aws-eks"
18-
GithubOrg = "terraform-aws-transit-gateway"
24+
Repository = "https://github.com/terraform-aws-modules/terraform-aws-transit-gateway"
1925
}
2026
}
2127

@@ -131,13 +137,13 @@ module "tgw_peer" {
131137

132138
module "vpc1" {
133139
source = "terraform-aws-modules/vpc/aws"
134-
version = "~> 5.0"
140+
version = "~> 6.0"
135141

136-
name = "${local.name}-vpc1"
137-
cidr = "10.10.0.0/16"
142+
name = "${local.name}-1"
143+
cidr = local.vpc1_cidr
138144

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

142148
enable_ipv6 = true
143149
private_subnet_assign_ipv6_address_on_creation = true
@@ -146,20 +152,15 @@ module "vpc1" {
146152
tags = local.tags
147153
}
148154

149-
150155
module "vpc2" {
151156
source = "terraform-aws-modules/vpc/aws"
152-
version = "~> 5.0"
153-
154-
providers = {
155-
aws = aws.peer
156-
}
157+
version = "~> 6.0"
157158

158-
name = "${local.name}-vpc2"
159-
cidr = "10.20.0.0/16"
159+
name = "${local.name}-2"
160+
cidr = local.vpc2_cidr
160161

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

164165
enable_ipv6 = false
165166

examples/multi-account/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.0"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.4"
7+
version = ">= 6.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)