Skip to content

Commit 4d85ad8

Browse files
committed
chore: Updates from testing
1 parent 571f2ba commit 4d85ad8

File tree

5 files changed

+28
-30
lines changed

5 files changed

+28
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ No modules.
192192
| <a name="input_enable_default_policy"></a> [enable\_default\_policy](#input\_enable\_default\_policy) | Specifies whether to enable the default key policy. Defaults to `true` | `bool` | `true` | no |
193193
| <a name="input_enable_key_rotation"></a> [enable\_key\_rotation](#input\_enable\_key\_rotation) | Specifies whether key rotation is enabled. Defaults to `true` | `bool` | `true` | no |
194194
| <a name="input_enable_route53_dnssec"></a> [enable\_route53\_dnssec](#input\_enable\_route53\_dnssec) | Determines whether the KMS policy used for Route53 DNSSEC signing is enabled | `bool` | `false` | no |
195-
| <a name="input_grants"></a> [grants](#input\_grants) | A map of grant definitions to create | <pre>map(object({<br/> constraints = optional(object({<br/> encryption_context_equals = optional(map(string))<br/> encryption_context_subset = optional(map(string))<br/> }))<br/> grant_creation_tokens = optional(string)<br/> grantee_principal = string<br/> name = optional(string) # Will fall back to use map key<br/> operations = list(string)<br/> retire_on_delete = optional(bool)<br/> retiring_principal = optional(string)<br/> }))</pre> | `null` | no |
195+
| <a name="input_grants"></a> [grants](#input\_grants) | A map of grant definitions to create | <pre>map(object({<br/> constraints = optional(list(object({<br/> encryption_context_equals = optional(map(string))<br/> encryption_context_subset = optional(map(string))<br/> })))<br/> grant_creation_tokens = optional(list(string))<br/> grantee_principal = string<br/> name = optional(string) # Will fall back to use map key<br/> operations = list(string)<br/> retire_on_delete = optional(bool)<br/> retiring_principal = optional(string)<br/> }))</pre> | `null` | no |
196196
| <a name="input_is_enabled"></a> [is\_enabled](#input\_is\_enabled) | Specifies whether the key is enabled. Defaults to `true` | `bool` | `null` | no |
197197
| <a name="input_key_administrators"></a> [key\_administrators](#input\_key\_administrators) | A list of IAM ARNs for [key administrators](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-default-allow-administrators) | `list(string)` | `[]` | no |
198198
| <a name="input_key_asymmetric_public_encryption_users"></a> [key\_asymmetric\_public\_encryption\_users](#input\_key\_asymmetric\_public\_encryption\_users) | A list of IAM ARNs for [key asymmetric public encryption users](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-users-crypto) | `list(string)` | `[]` | no |

examples/complete/main.tf

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ provider "aws" {
55
data "aws_caller_identity" "current" {}
66

77
locals {
8-
region = "us-east-1"
9-
name = "kms-ex-${basename(path.cwd)}"
8+
region = "us-east-1"
9+
region_secondary = "eu-west-1"
10+
name = "kms-ex-${basename(path.cwd)}"
1011

1112
account_id = data.aws_caller_identity.current.account_id
1213
current_identity = data.aws_caller_identity.current.arn
1314

15+
# Removes noise from hh:mm:ss in the timestamp
16+
valid_to = replace(timeadd(plantimestamp(), "4380h"), "/T.*/", "T00:00:00Z") # 6 months
17+
1418
tags = {
1519
Name = local.name
1620
Example = "complete"
@@ -62,7 +66,7 @@ module "kms_complete" {
6266
}
6367
]
6468

65-
conditions = [
69+
condition = [
6670
{
6771
test = "ArnLike"
6872
variable = "kms:EncryptionContext:aws:logs:arn"
@@ -93,11 +97,11 @@ module "kms_complete" {
9397
lambda = {
9498
grantee_principal = aws_iam_role.lambda.arn
9599
operations = ["Encrypt", "Decrypt", "GenerateDataKey"]
96-
constraints = {
100+
constraints = [{
97101
encryption_context_equals = {
98102
Department = "Finance"
99103
}
100-
}
104+
}]
101105
}
102106
}
103107

@@ -113,7 +117,7 @@ module "kms_external" {
113117
is_enabled = true
114118
key_material_base64 = "Wblj06fduthWggmsT0cLVoIMOkeLbc2kVfMud77i/JY="
115119
multi_region = false
116-
valid_to = "2023-11-21T23:20:50Z"
120+
valid_to = local.valid_to
117121

118122
tags = local.tags
119123
}
@@ -171,17 +175,10 @@ module "kms_primary" {
171175
tags = local.tags
172176
}
173177

174-
provider "aws" {
175-
region = "eu-west-1"
176-
alias = "replica"
177-
}
178-
179178
module "kms_replica" {
180179
source = "../.."
181180

182-
providers = {
183-
aws = aws.replica
184-
}
181+
region = local.region_secondary
185182

186183
deletion_window_in_days = 7
187184
description = "Replica key example showing various configurations available"
@@ -211,11 +208,11 @@ module "kms_replica" {
211208
lambda = {
212209
grantee_principal = aws_iam_role.lambda.arn
213210
operations = ["Encrypt", "Decrypt", "GenerateDataKey"]
214-
constraints = {
211+
constraints = [{
215212
encryption_context_equals = {
216213
Department = "Finance"
217214
}
218-
}
215+
}]
219216
}
220217
}
221218

@@ -235,7 +232,7 @@ module "kms_primary_external" {
235232
create_external = true
236233
key_material_base64 = "Wblj06fduthWggmsT0cLVoIMOkeLbc2kVfMud77i/JY="
237234
multi_region = true
238-
valid_to = "2023-11-21T23:20:50Z"
235+
valid_to = local.valid_to
239236

240237
aliases = ["primary-external"]
241238

@@ -245,9 +242,7 @@ module "kms_primary_external" {
245242
module "kms_replica_external" {
246243
source = "../.."
247244

248-
providers = {
249-
aws = aws.replica
250-
}
245+
region = local.region_secondary
251246

252247
deletion_window_in_days = 7
253248
description = "Replica external key example showing various configurations available"
@@ -256,7 +251,7 @@ module "kms_replica_external" {
256251
# key material must be the same as the primary's
257252
key_material_base64 = "Wblj06fduthWggmsT0cLVoIMOkeLbc2kVfMud77i/JY="
258253
primary_external_key_arn = module.kms_primary_external.key_arn
259-
valid_to = "2023-11-21T23:20:50Z"
254+
valid_to = local.valid_to
260255

261256
aliases = ["replica-external"]
262257

@@ -265,11 +260,11 @@ module "kms_replica_external" {
265260
lambda = {
266261
grantee_principal = aws_iam_role.lambda.arn
267262
operations = ["Encrypt", "Decrypt", "GenerateDataKey"]
268-
constraints = {
263+
constraints = [{
269264
encryption_context_equals = {
270265
Department = "Finance"
271266
}
272-
}
267+
}]
273268
}
274269
}
275270

examples/complete/outputs.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ output "complete_aliases" {
4040
output "complete_grants" {
4141
description = "A map of grants created and their attributes"
4242
value = module.kms_complete.grants
43+
sensitive = true
4344
}
4445

4546
################################################################################
@@ -84,6 +85,7 @@ output "external_aliases" {
8485
output "external_grants" {
8586
description = "A map of grants created and their attributes"
8687
value = module.kms_external.grants
88+
sensitive = true
8789
}
8890

8991
################################################################################
@@ -128,9 +130,9 @@ output "default_aliases" {
128130
output "default_grants" {
129131
description = "A map of grants created and their attributes"
130132
value = module.kms_default.grants
133+
sensitive = true
131134
}
132135

133-
134136
################################################################################
135137
# Replica
136138
################################################################################
@@ -173,9 +175,9 @@ output "replica_aliases" {
173175
output "replica_grants" {
174176
description = "A map of grants created and their attributes"
175177
value = module.kms_replica.grants
178+
sensitive = true
176179
}
177180

178-
179181
################################################################################
180182
# Replica External
181183
################################################################################
@@ -218,4 +220,5 @@ output "replica_external_aliases" {
218220
output "replica_external_grants" {
219221
description = "A map of grants created and their attributes"
220222
value = module.kms_replica_external.grants
223+
sensitive = true
221224
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ data "aws_iam_policy_document" "this" {
438438
}
439439

440440
dynamic "condition" {
441-
for_each = statement.value.conditions != null ? statement.value.conditions : []
441+
for_each = statement.value.condition != null ? statement.value.condition : []
442442

443443
content {
444444
test = condition.value.test

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ variable "aliases_use_name_prefix" {
280280
variable "grants" {
281281
description = "A map of grant definitions to create"
282282
type = map(object({
283-
constraints = optional(object({
283+
constraints = optional(list(object({
284284
encryption_context_equals = optional(map(string))
285285
encryption_context_subset = optional(map(string))
286-
}))
287-
grant_creation_tokens = optional(string)
286+
})))
287+
grant_creation_tokens = optional(list(string))
288288
grantee_principal = string
289289
name = optional(string) # Will fall back to use map key
290290
operations = list(string)

0 commit comments

Comments
 (0)