Skip to content

Commit 83c604c

Browse files
committed
feat: Raise MSV of Terraform
1 parent 2fbfb63 commit 83c604c

File tree

8 files changed

+42
-40
lines changed

8 files changed

+42
-40
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.96.1
3+
rev: v1.99.4
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
146146

147147
| Name | Version |
148148
|------|---------|
149-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
150-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.00 |
149+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
150+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
151151

152152
## Providers
153153

154154
| Name | Version |
155155
|------|---------|
156-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.00 |
156+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
157157

158158
## Modules
159159

examples/complete/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ Note that this example may create resources which will incur monetary charges on
2424

2525
| Name | Version |
2626
|------|---------|
27-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
28-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.49 |
27+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
28+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
2929

3030
## Providers
3131

3232
| Name | Version |
3333
|------|---------|
34-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.49 |
34+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
3535

3636
## Modules
3737

@@ -62,8 +62,6 @@ Note that this example may create resources which will incur monetary charges on
6262
|------|------|
6363
| [aws_iam_role.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
6464
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
65-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
66-
| [aws_region.replica](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
6765

6866
## Inputs
6967

examples/complete/main.tf

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

5+
data "aws_caller_identity" "current" {}
6+
57
locals {
6-
region = "us-east-1"
7-
replica_region = "eu-west-1"
8-
name = "kms-ex-${replace(basename(path.cwd), "_", "-")}"
8+
region = "us-east-1"
9+
replica_region = "eu-west-1"
10+
name = "kms-ex-${replace(basename(path.cwd), "_", "-")}"
11+
12+
account_id = data.aws_caller_identity.current.account_id
913
current_identity = data.aws_caller_identity.current.arn
1014

1115
tags = {
@@ -15,12 +19,6 @@ locals {
1519
}
1620
}
1721

18-
data "aws_caller_identity" "current" {}
19-
data "aws_region" "current" {}
20-
data "aws_region" "replica" {
21-
region = local.region
22-
}
23-
2422
################################################################################
2523
# KMS Module
2624
################################################################################
@@ -41,7 +39,7 @@ module "kms_complete" {
4139
key_administrators = [local.current_identity]
4240
key_users = [local.current_identity]
4341
key_service_users = [local.current_identity]
44-
key_service_roles_for_autoscaling = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]
42+
key_service_roles_for_autoscaling = ["arn:aws:iam::${local.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]
4543
key_symmetric_encryption_users = [local.current_identity]
4644
key_hmac_users = [local.current_identity]
4745
key_asymmetric_public_encryption_users = [local.current_identity]
@@ -61,7 +59,7 @@ module "kms_complete" {
6159
principals = [
6260
{
6361
type = "Service"
64-
identifiers = ["logs.${data.aws_region.current.region}.amazonaws.com"]
62+
identifiers = ["logs.${local.region}.amazonaws.com"]
6563
}
6664
]
6765

@@ -70,7 +68,7 @@ module "kms_complete" {
7068
test = "ArnLike"
7169
variable = "kms:EncryptionContext:aws:logs:arn"
7270
values = [
73-
"arn:aws:logs:${local.region}:${data.aws_caller_identity.current.account_id}:log-group:*",
71+
"arn:aws:logs:${local.region}:${local.account_id}:log-group:*",
7472
]
7573
}
7674
]
@@ -124,7 +122,7 @@ module "kms_complete_other_region" {
124122
key_administrators = [local.current_identity]
125123
key_users = [local.current_identity]
126124
key_service_users = [local.current_identity]
127-
key_service_roles_for_autoscaling = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]
125+
key_service_roles_for_autoscaling = ["arn:aws:iam::${local.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]
128126
key_symmetric_encryption_users = [local.current_identity]
129127
key_hmac_users = [local.current_identity]
130128
key_asymmetric_public_encryption_users = [local.current_identity]
@@ -144,7 +142,7 @@ module "kms_complete_other_region" {
144142
principals = [
145143
{
146144
type = "Service"
147-
identifiers = ["logs.${data.aws_region.replica.region}.amazonaws.com"]
145+
identifiers = ["logs.${local.replica_region}.amazonaws.com"]
148146
}
149147
]
150148

@@ -153,7 +151,7 @@ module "kms_complete_other_region" {
153151
test = "ArnLike"
154152
variable = "kms:EncryptionContext:aws:logs:arn"
155153
values = [
156-
"arn:aws:logs:${local.replica_region}:${data.aws_caller_identity.current.account_id}:log-group:*",
154+
"arn:aws:logs:${local.replica_region}:${local.account_id}:log-group:*",
157155
]
158156
}
159157
]
@@ -231,8 +229,8 @@ module "kms_dnssec_signing" {
231229
enable_key_rotation = false
232230
route53_dnssec_sources = [
233231
{
234-
accounts_ids = [data.aws_caller_identity.current.account_id] # can ommit if using current account ID which is default
235-
hosted_zone_arn = "arn:aws:route53:::hostedzone/*" # can ommit, this is default value
232+
accounts_ids = [local.account_id] # can ommit if using current account ID which is default
233+
hosted_zone_arn = "arn:aws:route53:::hostedzone/*" # can ommit, this is default value
236234
}
237235
]
238236

@@ -253,8 +251,8 @@ module "kms_dnssec_signing_other_region" {
253251
enable_key_rotation = false
254252
route53_dnssec_sources = [
255253
{
256-
accounts_ids = [data.aws_caller_identity.current.account_id] # can ommit if using current account ID which is default
257-
hosted_zone_arn = "arn:aws:route53:::hostedzone/*" # can ommit, this is default value
254+
accounts_ids = [local.account_id] # can ommit if using current account ID which is default
255+
hosted_zone_arn = "arn:aws:route53:::hostedzone/*" # can ommit, this is default value
258256
}
259257
]
260258
region = local.replica_region

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.3"
2+
required_version = ">= 1.5.7"
33

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

main.tf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ locals {
1818
resource "aws_kms_key" "this" {
1919
count = var.create && !var.create_external && !var.create_replica && !var.create_replica_external ? 1 : 0
2020

21+
region = var.region
22+
2123
bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
2224
customer_master_key_spec = var.customer_master_key_spec
2325
custom_key_store_id = var.custom_key_store_id
@@ -26,7 +28,6 @@ resource "aws_kms_key" "this" {
2628
enable_key_rotation = var.enable_key_rotation
2729
is_enabled = var.is_enabled
2830
key_usage = var.key_usage
29-
region = var.region
3031
multi_region = var.multi_region
3132
policy = coalesce(var.policy, data.aws_iam_policy_document.this[0].json)
3233
rotation_period_in_days = var.rotation_period_in_days
@@ -41,12 +42,13 @@ resource "aws_kms_key" "this" {
4142
resource "aws_kms_external_key" "this" {
4243
count = var.create && var.create_external && !var.create_replica && !var.create_replica_external ? 1 : 0
4344

45+
region = var.region
46+
4447
bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
4548
deletion_window_in_days = var.deletion_window_in_days
4649
description = var.description
4750
enabled = var.is_enabled
4851
key_material_base64 = var.key_material_base64
49-
region = var.region
5052
multi_region = var.multi_region
5153
policy = coalesce(var.policy, data.aws_iam_policy_document.this[0].json)
5254
valid_to = var.valid_to
@@ -61,13 +63,14 @@ resource "aws_kms_external_key" "this" {
6163
resource "aws_kms_replica_key" "this" {
6264
count = var.create && var.create_replica && !var.create_external && !var.create_replica_external ? 1 : 0
6365

66+
region = var.region
67+
6468
bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
6569
deletion_window_in_days = var.deletion_window_in_days
6670
description = var.description
6771
primary_key_arn = var.primary_key_arn
6872
enabled = var.is_enabled
6973
policy = coalesce(var.policy, data.aws_iam_policy_document.this[0].json)
70-
region = var.region
7174

7275
tags = var.tags
7376
}
@@ -79,6 +82,8 @@ resource "aws_kms_replica_key" "this" {
7982
resource "aws_kms_replica_external_key" "this" {
8083
count = var.create && !var.create_replica && !var.create_external && var.create_replica_external ? 1 : 0
8184

85+
region = var.region
86+
8287
bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
8388
deletion_window_in_days = var.deletion_window_in_days
8489
description = var.description
@@ -87,7 +92,6 @@ resource "aws_kms_replica_external_key" "this" {
8792
policy = coalesce(var.policy, data.aws_iam_policy_document.this[0].json)
8893
primary_key_arn = var.primary_external_key_arn
8994
valid_to = var.valid_to
90-
region = var.region
9195

9296
tags = var.tags
9397
}
@@ -457,10 +461,11 @@ locals {
457461
resource "aws_kms_alias" "this" {
458462
for_each = { for k, v in merge(local.aliases, var.computed_aliases) : k => v if var.create }
459463

464+
region = var.region
465+
460466
name = var.aliases_use_name_prefix ? null : "alias/${each.value.name}"
461467
name_prefix = var.aliases_use_name_prefix ? "alias/${each.value.name}-" : null
462468
target_key_id = try(aws_kms_key.this[0].key_id, aws_kms_external_key.this[0].id, aws_kms_replica_key.this[0].key_id, aws_kms_replica_external_key.this[0].key_id)
463-
region = var.region
464469
}
465470

466471
################################################################################
@@ -470,11 +475,12 @@ resource "aws_kms_alias" "this" {
470475
resource "aws_kms_grant" "this" {
471476
for_each = { for k, v in var.grants : k => v if var.create }
472477

478+
region = var.region
479+
473480
name = try(each.value.name, each.key)
474481
key_id = try(aws_kms_key.this[0].key_id, aws_kms_external_key.this[0].id, aws_kms_replica_key.this[0].key_id, aws_kms_replica_external_key.this[0].key_id)
475482
grantee_principal = each.value.grantee_principal
476483
operations = each.value.operations
477-
region = var.region
478484

479485
dynamic "constraints" {
480486
for_each = length(lookup(each.value, "constraints", {})) == 0 ? [] : [each.value.constraints]

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.3"
2+
required_version = ">= 1.5.7"
33

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

wrappers/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.3"
2+
required_version = ">= 1.5.7"
33

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

0 commit comments

Comments
 (0)