Skip to content

Commit 5178ca9

Browse files
committed
feat!: Upgrade AWS provider and min required Terraform version to 6.0 and 1.10 respectively
1 parent 5b17f94 commit 5178ca9

File tree

19 files changed

+964
-810
lines changed

19 files changed

+964
-810
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
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.98.0
3+
rev: v1.99.4
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 62 additions & 39 deletions
Large diffs are not rendered by default.

examples/complete/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Note that this example may create resources which can cost money. Run `terraform
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.66 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.10 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
2424

2525
## Providers
2626

2727
| Name | Version |
2828
|------|---------|
29-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66 |
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
3030

3131
## Modules
3232

@@ -45,7 +45,7 @@ Note that this example may create resources which can cost money. Run `terraform
4545
| <a name="module_ec2_t3_unlimited"></a> [ec2\_t3\_unlimited](#module\_ec2\_t3\_unlimited) | ../../ | n/a |
4646
| <a name="module_ec2_targeted_capacity_reservation"></a> [ec2\_targeted\_capacity\_reservation](#module\_ec2\_targeted\_capacity\_reservation) | ../../ | n/a |
4747
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
48-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
48+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
4949

5050
## Resources
5151

examples/complete/main.tf

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ module "ec2_complete" {
5959
threads_per_core = 1
6060
}
6161
enable_volume_tags = false
62-
root_block_device = [
63-
{
62+
root_block_device = {
63+
main = {
6464
encrypted = true
6565
volume_type = "gp3"
6666
throughput = 200
@@ -69,11 +69,10 @@ module "ec2_complete" {
6969
Name = "my-root-block"
7070
}
7171
},
72-
]
72+
}
7373

74-
ebs_block_device = [
75-
{
76-
device_name = "/dev/sdf"
74+
ebs_volumes = {
75+
"/dev/sdf" = {
7776
volume_type = "gp3"
7877
volume_size = 5
7978
throughput = 200
@@ -83,7 +82,7 @@ module "ec2_complete" {
8382
MountPoint = "/mnt/data"
8483
}
8584
}
86-
]
85+
}
8786

8887
tags = local.tags
8988
}
@@ -93,13 +92,12 @@ module "ec2_network_interface" {
9392

9493
name = "${local.name}-network-interface"
9594

96-
network_interface = [
97-
{
98-
device_index = 0
95+
network_interface = {
96+
0 = {
9997
network_interface_id = aws_network_interface.this.id
10098
delete_on_termination = false
10199
}
102-
]
100+
}
103101

104102
tags = local.tags
105103
}
@@ -109,8 +107,7 @@ module "ec2_metadata_options" {
109107

110108
name = "${local.name}-metadata-options"
111109

112-
subnet_id = element(module.vpc.private_subnets, 0)
113-
vpc_security_group_ids = [module.security_group.security_group_id]
110+
subnet_id = element(module.vpc.private_subnets, 0)
114111

115112
metadata_options = {
116113
http_endpoint = "enabled"
@@ -130,7 +127,6 @@ module "ec2_t2_unlimited" {
130127
instance_type = "t2.micro"
131128
cpu_credits = "unlimited"
132129
subnet_id = element(module.vpc.private_subnets, 0)
133-
vpc_security_group_ids = [module.security_group.security_group_id]
134130
associate_public_ip_address = true
135131

136132
maintenance_options = {
@@ -148,7 +144,6 @@ module "ec2_t3_unlimited" {
148144
instance_type = "t3.micro"
149145
cpu_credits = "unlimited"
150146
subnet_id = element(module.vpc.private_subnets, 0)
151-
vpc_security_group_ids = [module.security_group.security_group_id]
152147
associate_public_ip_address = true
153148

154149
tags = local.tags
@@ -171,11 +166,10 @@ module "ec2_ignore_ami_changes" {
171166

172167
ignore_ami_changes = true
173168

174-
ami = data.aws_ami.amazon_linux.id
175-
instance_type = "t2.micro"
176-
availability_zone = element(module.vpc.azs, 0)
177-
subnet_id = element(module.vpc.private_subnets, 0)
178-
vpc_security_group_ids = [module.security_group.security_group_id]
169+
ami = data.aws_ami.amazon_linux.id
170+
instance_type = "t2.micro"
171+
availability_zone = element(module.vpc.azs, 0)
172+
subnet_id = element(module.vpc.private_subnets, 0)
179173

180174
tags = local.tags
181175
}
@@ -190,8 +184,8 @@ locals {
190184
instance_type = "t3.micro"
191185
availability_zone = element(module.vpc.azs, 0)
192186
subnet_id = element(module.vpc.private_subnets, 0)
193-
root_block_device = [
194-
{
187+
root_block_device = {
188+
main = {
195189
encrypted = true
196190
volume_type = "gp3"
197191
throughput = 200
@@ -200,19 +194,19 @@ locals {
200194
Name = "my-root-block"
201195
}
202196
}
203-
]
197+
}
204198
}
205199
two = {
206200
instance_type = "t3.small"
207201
availability_zone = element(module.vpc.azs, 1)
208202
subnet_id = element(module.vpc.private_subnets, 1)
209-
root_block_device = [
210-
{
203+
root_block_device = {
204+
main = {
211205
encrypted = true
212206
volume_type = "gp2"
213207
volume_size = 50
214208
}
215-
]
209+
}
216210
}
217211
three = {
218212
instance_type = "t3.medium"
@@ -229,13 +223,12 @@ module "ec2_multiple" {
229223

230224
name = "${local.name}-multi-${each.key}"
231225

232-
instance_type = each.value.instance_type
233-
availability_zone = each.value.availability_zone
234-
subnet_id = each.value.subnet_id
235-
vpc_security_group_ids = [module.security_group.security_group_id]
226+
instance_type = each.value.instance_type
227+
availability_zone = each.value.availability_zone
228+
subnet_id = each.value.subnet_id
236229

237230
enable_volume_tags = false
238-
root_block_device = lookup(each.value, "root_block_device", [])
231+
root_block_device = try(each.value.root_block_device, null)
239232

240233
tags = local.tags
241234
}
@@ -256,10 +249,9 @@ module "ec2_spot_instance" {
256249
associate_public_ip_address = true
257250

258251
# Spot request specific attributes
259-
spot_price = "0.1"
260-
spot_wait_for_fulfillment = true
261-
spot_type = "persistent"
262-
spot_instance_interruption_behavior = "terminate"
252+
spot_price = "0.1"
253+
spot_wait_for_fulfillment = true
254+
spot_type = "persistent"
263255
# End spot request specific attributes
264256

265257
user_data_base64 = base64encode(local.user_data)
@@ -270,28 +262,27 @@ module "ec2_spot_instance" {
270262
}
271263

272264
enable_volume_tags = false
273-
root_block_device = [
274-
{
265+
root_block_device = {
266+
main = {
275267
encrypted = true
276268
volume_type = "gp3"
277269
throughput = 200
278270
volume_size = 50
279271
tags = {
280272
Name = "my-root-block"
281273
}
282-
},
283-
]
274+
}
275+
}
284276

285-
ebs_block_device = [
286-
{
287-
device_name = "/dev/sdf"
277+
ebs_volumes = {
278+
"/dev/sdf" = {
288279
volume_type = "gp3"
289280
volume_size = 5
290281
throughput = 200
291282
encrypted = true
292283
# kms_key_id = aws_kms_key.this.arn # you must grant the AWSServiceRoleForEC2Spot service-linked role access to any custom KMS keys
293284
}
294-
]
285+
}
295286

296287
tags = local.tags
297288
}
@@ -308,7 +299,6 @@ module "ec2_open_capacity_reservation" {
308299
ami = data.aws_ami.amazon_linux.id
309300
instance_type = "t3.micro"
310301
subnet_id = element(module.vpc.private_subnets, 0)
311-
vpc_security_group_ids = [module.security_group.security_group_id]
312302
associate_public_ip_address = false
313303

314304
capacity_reservation_specification = {
@@ -328,7 +318,6 @@ module "ec2_targeted_capacity_reservation" {
328318
ami = data.aws_ami.amazon_linux.id
329319
instance_type = "t3.micro"
330320
subnet_id = element(module.vpc.private_subnets, 0)
331-
vpc_security_group_ids = [module.security_group.security_group_id]
332321
associate_public_ip_address = false
333322

334323
capacity_reservation_specification = {
@@ -369,7 +358,6 @@ module "ec2_cpu_options" {
369358
instance_type = "c6a.xlarge" # used to set core count below and test amd_sev_snp attribute
370359
availability_zone = element(module.vpc.azs, 0)
371360
subnet_id = element(module.vpc.private_subnets, 0)
372-
vpc_security_group_ids = [module.security_group.security_group_id]
373361
placement_group = aws_placement_group.web.id
374362
associate_public_ip_address = true
375363
disable_api_stop = false
@@ -389,22 +377,20 @@ module "ec2_cpu_options" {
389377
amd_sev_snp = "enabled"
390378
}
391379
enable_volume_tags = false
392-
root_block_device = [
393-
{
380+
root_block_device = {
381+
main = {
394382
encrypted = true
395383
volume_type = "gp3"
396384
throughput = 200
397385
volume_size = 50
398386
tags = {
399387
Name = "my-root-block"
400388
}
401-
},
402-
]
389+
}
390+
}
403391

404-
ebs_block_device = [
405-
{
406-
device_name = "/dev/sdf"
407-
volume_type = "gp3"
392+
ebs_volumes = {
393+
"/dev/sdf" = {
408394
volume_size = 5
409395
throughput = 200
410396
encrypted = true
@@ -413,7 +399,7 @@ module "ec2_cpu_options" {
413399
MountPoint = "/mnt/data"
414400
}
415401
}
416-
]
402+
}
417403

418404
instance_tags = { Persistence = "09:00-18:00" }
419405

@@ -426,7 +412,7 @@ module "ec2_cpu_options" {
426412

427413
module "vpc" {
428414
source = "terraform-aws-modules/vpc/aws"
429-
version = "~> 5.0"
415+
version = "~> 6.0"
430416

431417
name = local.name
432418
cidr = local.vpc_cidr
@@ -466,9 +452,7 @@ module "security_group" {
466452
description = "Security group for example usage with EC2 instance"
467453
vpc_id = module.vpc.vpc_id
468454

469-
ingress_cidr_blocks = ["0.0.0.0/0"]
470-
ingress_rules = ["http-80-tcp", "all-icmp"]
471-
egress_rules = ["all-all"]
455+
ingress_rules = ["http-80-tcp", "all-icmp"]
472456

473457
tags = local.tags
474458
}

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.10"
33

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

examples/session-manager/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,22 @@ Note that this example may create resources which can cost money. Run `terraform
2929

3030
| Name | Version |
3131
|------|---------|
32-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
33-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66 |
32+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.10 |
33+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
3434

3535
## Providers
3636

3737
| Name | Version |
3838
|------|---------|
39-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66 |
39+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
4040

4141
## Modules
4242

4343
| Name | Source | Version |
4444
|------|--------|---------|
4545
| <a name="module_ec2"></a> [ec2](#module\_ec2) | ../../ | n/a |
46-
| <a name="module_security_group_instance"></a> [security\_group\_instance](#module\_security\_group\_instance) | terraform-aws-modules/security-group/aws | ~> 5.0 |
47-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
48-
| <a name="module_vpc_endpoints"></a> [vpc\_endpoints](#module\_vpc\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 5.0 |
46+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
47+
| <a name="module_vpc_endpoints"></a> [vpc\_endpoints](#module\_vpc\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 6.0 |
4948

5049
## Resources
5150

0 commit comments

Comments
 (0)