You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[aws_iam_policy_document.predefined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
@@ -48,6 +49,7 @@ This module creates following resources.
48
49
| <aname="input_deletion_window_in_days"></a> [deletion\_window\_in\_days](#input\_deletion\_window\_in\_days)| (Optional) Duration in days after which the key is deleted after destruction of the resource. Valid value is between `7` and `30` days. Defaults to `30`. |`number`|`30`| no |
49
50
| <aname="input_description"></a> [description](#input\_description)| (Optional) The description of the KMS key. |`string`|`"Managed by Terraform."`| no |
50
51
| <aname="input_enabled"></a> [enabled](#input\_enabled)| (Optional) Indicates whether the key is enabled. Defaults to `true`. |`bool`|`true`| no |
52
+
| <a name="input_grants"></a> [grants](#input\_grants) | (Optional) A list of grants configuration for granting access to the KMS key. Each item of `grants` as defined below.<br/> (Required) `name` - A friendly name for the grant.<br/> (Required) `grantee_principal` - The principal that is given permission to perform the operations that the grant permits in ARN format.<br/> (Required) `operations` - A set of operations that the grant permits. Valid values are `Encrypt`, `Decrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, `GenerateDataKeyPairWithoutPlaintext`, `GetPublicKey`, `Sign`, `Verify`, `GenerateMac`, `VerifyMac`, or `DeriveSharedSecret`.<br/> (Optional) `retiring_principal` - The principal that is given permission to retire the grant by using RetireGrant operation in ARN format.<br/> (Optional) `retire_on_delete` - Whether to retire the grant upon deletion. Defaults to `false`.<br/> Retire: Grantee returns permissions voluntarily (normal termination)<br/> Revoke: Admin forcefully cancels permissions (emergency termination)<br/> (Optional) `grant_creation_tokens` - A list of grant tokens to be used when creating the grant. Use grant token for immediate access without waiting for grant propagation (up to 5 min). Required for time-sensitive operations.<br/> (Optional) `constraints` - A configuration for grant constraints. `constraints` block as defined below.<br/> (Optional) `type` - The type of constraints. Valid values are `ENCRYPTION_CONTEXT_EQUALS` or `ENCRYPTION_CONTEXT_SUBSET`. Defaults to `ENCRYPTION_CONTEXT_SUBSET`.<br/> (Optional) `value` - A map of key-value pair to be validated against the encryption context during cryptographic operations. | <pre>list(object({<br/> name = string<br/> grantee_principal = string<br/> operations = set(string)<br/><br/> retiring_principal = optional(string)<br/> retire_on_delete = optional(bool, false)<br/> grant_creation_tokens = optional(list(string))<br/><br/> constraints = optional(object({<br/> type = optional(string, "ENCRYPTION_CONTEXT_SUBSET")<br/> value = map(string)<br/> }))<br/> }))</pre> | `[]` | no |
51
53
| <aname="input_key_rotation"></a> [key\_rotation](#input\_key\_rotation)| (Optional) A configuration for key rotation of the KMS key. This configuration is only applicable for symmetric encryption KMS keys. `key_rotation` block as defined below.<br/> (Optional) `enabled` - Whether key rotation is enabled. Defaults to `false`.<br/> (Optional) `period_in_days` - The custom period of t ime between each key rotation. Valid value is between `90` and `2560` days (inclusive). Defaults to `365`. | <pre>object({<br/> enabled = optional(bool, false)<br/> period_in_days = optional(number, 365)<br/> })</pre> |`{}`| no |
52
54
| <aname="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled)| (Optional) Whether to create AWS Resource Tags for the module informations. |`bool`|`true`| no |
53
55
| <aname="input_multi_region_enabled"></a> [multi\_region\_enabled](#input\_multi\_region\_enabled)| (Optional) Indicates whether the key is a multi-Region (true) or regional (false) key. Defaults to `false`. |`bool`|`false`| no |
@@ -71,6 +73,7 @@ This module creates following resources.
71
73
| <aname="output_deletion_window_in_days"></a> [deletion\_window\_in\_days](#output\_deletion\_window\_in\_days)| Duration in days after which the key is deleted after destruction of the resource. |
72
74
| <aname="output_description"></a> [description](#output\_description)| The description of the KMS key. |
73
75
| <aname="output_enabled"></a> [enabled](#output\_enabled)| Whether the key is enabled. |
76
+
| <aname="output_grants"></a> [grants](#output\_grants)| A collection of grants for the key. |
74
77
| <aname="output_id"></a> [id](#output\_id)| The ID of the KMS key. |
75
78
| <aname="output_key_rotation"></a> [key\_rotation](#output\_key\_rotation)| The key rotation configuration of the KMS key. |
76
79
| <aname="output_multi_region_enabled"></a> [multi\_region\_enabled](#output\_multi\_region\_enabled)| Whether the key is a multi-region key. |
# NOTE: `grant_token` is intentionally not included in outputs because :
65
+
# - Grant tokens are only returned during grant creation and cannot be retrieved afterwards
66
+
# - Since Terraform-managed grants are created during infrastructure provisioning, they are already propagated by the time applications run, making tokens unnecessary
67
+
# - For immediate access needs, applications should create grants at runtime and use the returned tokens directly rather than relying on pre-provisioned grants
68
+
output"grants" {
69
+
description="A collection of grants for the key."
70
+
value=local.grants
71
+
}
72
+
49
73
output"predefined_roles" {
50
74
description="The predefined roles that have access to the KMS key."
Copy file name to clipboardExpand all lines: modules/kms-key/variables.tf
+84Lines changed: 84 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,90 @@ variable "key_rotation" {
103
103
}
104
104
}
105
105
106
+
variable"grants" {
107
+
description=<<EOF
108
+
(Optional) A list of grants configuration for granting access to the KMS key. Each item of `grants` as defined below.
109
+
(Required) `name` - A friendly name for the grant.
110
+
(Required) `grantee_principal` - The principal that is given permission to perform the operations that the grant permits in ARN format.
111
+
(Required) `operations` - A set of operations that the grant permits. Valid values are `Encrypt`, `Decrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, `GenerateDataKeyPairWithoutPlaintext`, `GetPublicKey`, `Sign`, `Verify`, `GenerateMac`, `VerifyMac`, or `DeriveSharedSecret`.
112
+
(Optional) `retiring_principal` - The principal that is given permission to retire the grant by using RetireGrant operation in ARN format.
113
+
(Optional) `retire_on_delete` - Whether to retire the grant upon deletion. Defaults to `false`.
(Optional) `grant_creation_tokens` - A list of grant tokens to be used when creating the grant. Use grant token for immediate access without waiting for grant propagation (up to 5 min). Required for time-sensitive operations.
117
+
(Optional) `constraints` - A configuration for grant constraints. `constraints` block as defined below.
118
+
(Optional) `type` - The type of constraints. Valid values are `ENCRYPTION_CONTEXT_EQUALS` or `ENCRYPTION_CONTEXT_SUBSET`. Defaults to `ENCRYPTION_CONTEXT_SUBSET`.
119
+
(Optional) `value` - A map of key-value pair to be validated against the encryption context during cryptographic operations.
120
+
EOF
121
+
type=list(object({
122
+
name =string
123
+
grantee_principal =string
124
+
operations =set(string)
125
+
126
+
retiring_principal =optional(string)
127
+
retire_on_delete =optional(bool, false)
128
+
grant_creation_tokens =optional(list(string))
129
+
130
+
constraints =optional(object({
131
+
type =optional(string, "ENCRYPTION_CONTEXT_SUBSET")
132
+
value =map(string)
133
+
}))
134
+
}))
135
+
default=[]
136
+
nullable=false
137
+
138
+
validation {
139
+
condition=alltrue([
140
+
forgrantinvar.grants:
141
+
alltrue([
142
+
foropingrant.operations:
143
+
contains([
144
+
"Encrypt",
145
+
"Decrypt",
146
+
"GenerateDataKey",
147
+
"GenerateDataKeyWithoutPlaintext",
148
+
"ReEncryptFrom",
149
+
"ReEncryptTo",
150
+
"CreateGrant",
151
+
"RetireGrant",
152
+
"DescribeKey",
153
+
"GenerateDataKeyPair",
154
+
"GenerateDataKeyPairWithoutPlaintext",
155
+
"GetPublicKey",
156
+
"Sign",
157
+
"Verify",
158
+
"GenerateMac",
159
+
"VerifyMac",
160
+
"DeriveSharedSecret",
161
+
], op)
162
+
])
163
+
])
164
+
error_message="Valid values for grant operations are `Encrypt`, `Decrypt`, `GenerateDataKey`, `GenerateDataKeyWithoutPlaintext`, `ReEncryptFrom`, `ReEncryptTo`, `CreateGrant`, `RetireGrant`, `DescribeKey`, `GenerateDataKeyPair`, `GenerateDataKeyPairWithoutPlaintext`, `GetPublicKey`, `Sign`, `Verify`, `GenerateMac`, `VerifyMac`, or `DeriveSharedSecret`."
165
+
}
166
+
167
+
validation {
168
+
condition=alltrue([
169
+
forgrantinvar.grants:
170
+
contains([
171
+
"ENCRYPTION_CONTEXT_EQUALS",
172
+
"ENCRYPTION_CONTEXT_SUBSET"
173
+
], grant.constraints.type)
174
+
ifgrant.constraints!=null
175
+
])
176
+
error_message="Valid values for `constraints.type` are `ENCRYPTION_CONTEXT_EQUALS` or `ENCRYPTION_CONTEXT_SUBSET`."
error_message="If `constraints` is defined, it must contain at least one key-value pair in `value`."
187
+
}
188
+
}
189
+
106
190
variable"predefined_roles" {
107
191
description=<<EOF
108
192
(Optional) A configuration for predefined roles of the KMS key. This configuration will be merged with given `policy` if it is defined. `predefined_roles` block as defined below.
0 commit comments