Skip to content

Commit 850b8bd

Browse files
feat!: Update Terraform and AWS provider versions to 1.11 and 6.0 respectively (#14)
Co-authored-by: Bryant Biggs <[email protected]>
1 parent f7749e2 commit 850b8bd

File tree

10 files changed

+147
-69
lines changed

10 files changed

+147
-69
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.100.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

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

124124
| Name | Version |
125125
|------|---------|
126-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
127-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
128-
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
126+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.11 |
127+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
128+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.7 |
129129

130130
## Providers
131131

132132
| Name | Version |
133133
|------|---------|
134-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
135-
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0 |
134+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
136135

137136
## Modules
138137

@@ -147,7 +146,6 @@ No modules.
147146
| [aws_secretsmanager_secret_rotation.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_rotation) | resource |
148147
| [aws_secretsmanager_secret_version.ignore_changes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
149148
| [aws_secretsmanager_secret_version.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
150-
| [random_password.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
151149
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
152150

153151
## Inputs
@@ -157,7 +155,7 @@ No modules.
157155
| <a name="input_block_public_policy"></a> [block\_public\_policy](#input\_block\_public\_policy) | Makes an optional API call to Zelkova to validate the Resource Policy to prevent broad access to your secret | `bool` | `null` | no |
158156
| <a name="input_create"></a> [create](#input\_create) | Determines whether resources will be created (affects all resources) | `bool` | `true` | no |
159157
| <a name="input_create_policy"></a> [create\_policy](#input\_create\_policy) | Determines whether a policy will be created | `bool` | `false` | no |
160-
| <a name="input_create_random_password"></a> [create\_random\_password](#input\_create\_random\_password) | Determines whether a random password will be generated | `bool` | `false` | no |
158+
| <a name="input_create_random_password"></a> [create\_random\_password](#input\_create\_random\_password) | Determines whether an ephemeral random password will be generated for `secret_string_wo` | `bool` | `false` | no |
161159
| <a name="input_description"></a> [description](#input\_description) | A description of the secret | `string` | `null` | no |
162160
| <a name="input_enable_rotation"></a> [enable\_rotation](#input\_enable\_rotation) | Determines whether secret rotation is enabled | `bool` | `false` | no |
163161
| <a name="input_force_overwrite_replica_secret"></a> [force\_overwrite\_replica\_secret](#input\_force\_overwrite\_replica\_secret) | Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region | `bool` | `null` | no |
@@ -166,15 +164,19 @@ No modules.
166164
| <a name="input_name"></a> [name](#input\_name) | Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` | `string` | `null` | no |
167165
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Creates a unique name beginning with the specified prefix | `string` | `null` | no |
168166
| <a name="input_override_policy_documents"></a> [override\_policy\_documents](#input\_override\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |
169-
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage | `map(any)` | `{}` | no |
167+
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage | <pre>map(object({<br/> sid = optional(string)<br/> actions = optional(list(string))<br/> not_actions = optional(list(string))<br/> effect = optional(string)<br/> resources = optional(list(string))<br/> not_resources = optional(list(string))<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> not_principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> condition = optional(list(object({<br/> test = string<br/> values = list(string)<br/> variable = string<br/> })))<br/> }))</pre> | `null` | no |
170168
| <a name="input_random_password_length"></a> [random\_password\_length](#input\_random\_password\_length) | The length of the generated random password | `number` | `32` | no |
171169
| <a name="input_random_password_override_special"></a> [random\_password\_override\_special](#input\_random\_password\_override\_special) | Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument | `string` | `"!@#$%&*()-_=+[]{}<>:?"` | no |
172170
| <a name="input_recovery_window_in_days"></a> [recovery\_window\_in\_days](#input\_recovery\_window\_in\_days) | Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30` | `number` | `null` | no |
173-
| <a name="input_replica"></a> [replica](#input\_replica) | Configuration block to support secret replication | `map(any)` | `{}` | no |
171+
| <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 |
172+
| <a name="input_replica"></a> [replica](#input\_replica) | Configuration block to support secret replication | <pre>map(object({<br/> kms_key_id = optional(string)<br/> region = optional(string) # will default to the key name<br/> }))</pre> | `null` | no |
173+
| <a name="input_rotate_immediately"></a> [rotate\_immediately](#input\_rotate\_immediately) | Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. The rotation schedule is defined in `rotation_rules` | `bool` | `null` | no |
174174
| <a name="input_rotation_lambda_arn"></a> [rotation\_lambda\_arn](#input\_rotation\_lambda\_arn) | Specifies the ARN of the Lambda function that can rotate the secret | `string` | `""` | no |
175-
| <a name="input_rotation_rules"></a> [rotation\_rules](#input\_rotation\_rules) | A structure that defines the rotation configuration for this secret | `map(any)` | `{}` | no |
176-
| <a name="input_secret_binary"></a> [secret\_binary](#input\_secret\_binary) | Specifies binary data that you want to encrypt and store in this version of the secret. This is required if `secret_string` is not set. Needs to be encoded to base64 | `string` | `null` | no |
177-
| <a name="input_secret_string"></a> [secret\_string](#input\_secret\_string) | Specifies text data that you want to encrypt and store in this version of the secret. This is required if `secret_binary` is not set | `string` | `null` | no |
175+
| <a name="input_rotation_rules"></a> [rotation\_rules](#input\_rotation\_rules) | A structure that defines the rotation configuration for this secret | <pre>object({<br/> automatically_after_days = optional(number)<br/> duration = optional(string)<br/> schedule_expression = optional(string)<br/> })</pre> | `null` | no |
176+
| <a name="input_secret_binary"></a> [secret\_binary](#input\_secret\_binary) | Specifies binary data that you want to encrypt and store in this version of the secret. This is required if `secret_string` or `secret_string_wo` is not set. Needs to be encoded to base64 | `string` | `null` | no |
177+
| <a name="input_secret_string"></a> [secret\_string](#input\_secret\_string) | Specifies text data that you want to encrypt and store in this version of the secret. This is required if `secret_binary` or `secret_string_wo` is not set | `string` | `null` | no |
178+
| <a name="input_secret_string_wo"></a> [secret\_string\_wo](#input\_secret\_string\_wo) | Specifies text data that you want to encrypt and store in this version of the secret. This is required if `secret_binary` or `secret_string` is not set | `string` | `null` | no |
179+
| <a name="input_secret_string_wo_version"></a> [secret\_string\_wo\_version](#input\_secret\_string\_wo\_version) | Used together with `secret_string_wo` to trigger an update. Increment this value when an update to `secret_string_wo` is required | `string` | `null` | no |
178180
| <a name="input_source_policy_documents"></a> [source\_policy\_documents](#input\_source\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |
179181
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
180182
| <a name="input_version_stages"></a> [version\_stages](#input\_version\_stages) | Specifies a list of staging labels that are attached to this version of the secret. A staging label must be unique to a single version of the secret | `list(string)` | `null` | no |

examples/complete/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ Note that this example may create resources which will incur monetary charges on
2828

2929
| Name | Version |
3030
|------|---------|
31-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
32-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
31+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.11 |
32+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
33+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.7 |
3334

3435
## Providers
3536

3637
| Name | Version |
3738
|------|---------|
38-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
39+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
3940

4041
## Modules
4142

4243
| Name | Source | Version |
4344
|------|--------|---------|
44-
| <a name="module_lambda"></a> [lambda](#module\_lambda) | terraform-aws-modules/lambda/aws | ~> 6.0 |
45+
| <a name="module_lambda"></a> [lambda](#module\_lambda) | terraform-aws-modules/lambda/aws | ~> 8.0 |
4546
| <a name="module_secrets_manager"></a> [secrets\_manager](#module\_secrets\_manager) | ../.. | n/a |
4647
| <a name="module_secrets_manager_disabled"></a> [secrets\_manager\_disabled](#module\_secrets\_manager\_disabled) | ../.. | n/a |
4748
| <a name="module_secrets_manager_rotate"></a> [secrets\_manager\_rotate](#module\_secrets\_manager\_rotate) | ../.. | n/a |

examples/complete/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ module "secrets_manager_rotate" {
101101
engine = "mariadb",
102102
host = "mydb.cluster-123456789012.us-east-1.rds.amazonaws.com",
103103
username = "Bill",
104-
password = "ThisIsMySuperSecretString12356!"
104+
password = "ThisIsMySuperSecretString12356!",
105105
dbname = "mydb",
106106
port = 3306
107107
})
@@ -152,13 +152,13 @@ data "aws_iam_policy_document" "this" {
152152

153153
module "lambda" {
154154
source = "terraform-aws-modules/lambda/aws"
155-
version = "~> 6.0"
155+
version = "~> 8.0"
156156

157157
function_name = local.name
158158
description = "Example Secrets Manager secret rotation lambda function"
159159

160160
handler = "function.lambda_handler"
161-
runtime = "python3.10"
161+
runtime = "python3.13"
162162
timeout = 60
163163
memory_size = 512
164164
source_path = "${path.module}/function.py"

examples/complete/versions.tf

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

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.0"
7+
version = ">= 6.0"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = ">= 3.7"
812
}
913
}
1014
}

main.tf

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
resource "aws_secretsmanager_secret" "this" {
77
count = var.create ? 1 : 0
88

9+
region = var.region
10+
911
description = var.description
1012
force_overwrite_replica_secret = var.force_overwrite_replica_secret
1113
kms_key_id = var.kms_key_id
@@ -14,11 +16,11 @@ resource "aws_secretsmanager_secret" "this" {
1416
recovery_window_in_days = var.recovery_window_in_days
1517

1618
dynamic "replica" {
17-
for_each = var.replica
19+
for_each = var.replica != null ? var.replica : {}
1820

1921
content {
20-
kms_key_id = try(replica.value.kms_key_id, null)
21-
region = try(replica.value.region, replica.key)
22+
kms_key_id = replica.value.kms_key_id
23+
region = coalesce(replica.value.region, replica.key)
2224
}
2325
}
2426

@@ -36,18 +38,18 @@ data "aws_iam_policy_document" "this" {
3638
override_policy_documents = var.override_policy_documents
3739

3840
dynamic "statement" {
39-
for_each = var.policy_statements
41+
for_each = var.policy_statements != null ? var.policy_statements : {}
4042

4143
content {
42-
sid = try(statement.value.sid, null)
43-
actions = try(statement.value.actions, null)
44-
not_actions = try(statement.value.not_actions, null)
45-
effect = try(statement.value.effect, null)
46-
resources = try(statement.value.resources, null)
47-
not_resources = try(statement.value.not_resources, null)
44+
sid = statement.value.sid
45+
actions = statement.value.actions
46+
not_actions = statement.value.not_actions
47+
effect = statement.value.effect
48+
resources = statement.value.resources
49+
not_resources = statement.value.not_resources
4850

4951
dynamic "principals" {
50-
for_each = try(statement.value.principals, [])
52+
for_each = statement.value.principals != null ? statement.value.principals : []
5153

5254
content {
5355
type = principals.value.type
@@ -56,7 +58,7 @@ data "aws_iam_policy_document" "this" {
5658
}
5759

5860
dynamic "not_principals" {
59-
for_each = try(statement.value.not_principals, [])
61+
for_each = statement.value.not_principals != null ? statement.value.not_principals : []
6062

6163
content {
6264
type = not_principals.value.type
@@ -65,7 +67,7 @@ data "aws_iam_policy_document" "this" {
6567
}
6668

6769
dynamic "condition" {
68-
for_each = try(statement.value.conditions, [])
70+
for_each = statement.value.condition != null ? statement.value.condition : []
6971

7072
content {
7173
test = condition.value.test
@@ -80,9 +82,11 @@ data "aws_iam_policy_document" "this" {
8082
resource "aws_secretsmanager_secret_policy" "this" {
8183
count = var.create && var.create_policy ? 1 : 0
8284

83-
secret_arn = aws_secretsmanager_secret.this[0].arn
84-
policy = data.aws_iam_policy_document.this[0].json
85+
region = var.region
86+
8587
block_public_policy = var.block_public_policy
88+
policy = data.aws_iam_policy_document.this[0].json
89+
secret_arn = aws_secretsmanager_secret.this[0].arn
8690
}
8791

8892
################################################################################
@@ -92,19 +96,27 @@ resource "aws_secretsmanager_secret_policy" "this" {
9296
resource "aws_secretsmanager_secret_version" "this" {
9397
count = var.create && !(var.enable_rotation || var.ignore_secret_changes) ? 1 : 0
9498

95-
secret_id = aws_secretsmanager_secret.this[0].id
96-
secret_string = var.create_random_password ? random_password.this[0].result : var.secret_string
97-
secret_binary = var.secret_binary
98-
version_stages = var.version_stages
99+
region = var.region
100+
101+
secret_id = aws_secretsmanager_secret.this[0].id
102+
secret_binary = var.secret_binary
103+
secret_string = var.secret_string
104+
secret_string_wo = var.create_random_password ? ephemeral.random_password.this[0].result : var.secret_string_wo
105+
secret_string_wo_version = var.create_random_password ? coalesce(var.secret_string_wo_version, 0) : var.secret_string_wo_version
106+
version_stages = var.version_stages
99107
}
100108

101109
resource "aws_secretsmanager_secret_version" "ignore_changes" {
102110
count = var.create && (var.enable_rotation || var.ignore_secret_changes) ? 1 : 0
103111

104-
secret_id = aws_secretsmanager_secret.this[0].id
105-
secret_string = var.create_random_password ? random_password.this[0].result : var.secret_string
106-
secret_binary = var.secret_binary
107-
version_stages = var.version_stages
112+
region = var.region
113+
114+
secret_id = aws_secretsmanager_secret.this[0].id
115+
secret_binary = var.secret_binary
116+
secret_string = var.secret_string
117+
secret_string_wo = var.create_random_password ? ephemeral.random_password.this[0].result : var.secret_string_wo
118+
secret_string_wo_version = var.create_random_password ? coalesce(var.secret_string_wo_version, 0) : var.secret_string_wo_version
119+
version_stages = var.version_stages
108120

109121
lifecycle {
110122
ignore_changes = [
@@ -115,7 +127,7 @@ resource "aws_secretsmanager_secret_version" "ignore_changes" {
115127
}
116128
}
117129

118-
resource "random_password" "this" {
130+
ephemeral "random_password" "this" {
119131
count = var.create && var.create_random_password ? 1 : 0
120132

121133
length = var.random_password_length
@@ -130,15 +142,18 @@ resource "random_password" "this" {
130142
resource "aws_secretsmanager_secret_rotation" "this" {
131143
count = var.create && var.enable_rotation ? 1 : 0
132144

145+
region = var.region
146+
147+
rotate_immediately = var.rotate_immediately
133148
rotation_lambda_arn = var.rotation_lambda_arn
134149

135150
dynamic "rotation_rules" {
136-
for_each = [var.rotation_rules]
151+
for_each = var.rotation_rules != null ? [var.rotation_rules] : []
137152

138153
content {
139-
automatically_after_days = try(rotation_rules.value.automatically_after_days, null)
140-
duration = try(rotation_rules.value.duration, null)
141-
schedule_expression = try(rotation_rules.value.schedule_expression, null)
154+
automatically_after_days = rotation_rules.value.automatically_after_days
155+
duration = rotation_rules.value.duration
156+
schedule_expression = rotation_rules.value.schedule_expression
142157
}
143158
}
144159

0 commit comments

Comments
 (0)