Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

Commit 1cf233f

Browse files
kavya498hkantare
authored andcommitted
Support: Policies in KMS
1 parent cd77e66 commit 1cf233f

File tree

11 files changed

+60
-2
lines changed

11 files changed

+60
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module "kms_key" {
4949

5050
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5151

52+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
5253
## Usage
5354

5455
To run this example you need to execute:

examples/import-key/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module "kms_key" {
4646

4747
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4848

49+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
4950
## Usage
5051

5152
To run this example you need to execute:

examples/instance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module "kms_instance" {
3131

3232
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3333

34+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
3435
## Usage
3536

3637
To run this example you need to execute:

examples/instance/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# IBM Cloud Key Management Services Provisioning and Managing Keys
33
# Copyright 2021 IBM
44
#########################################################################################
5+
56
data "ibm_resource_group" "resource_group" {
67
name = var.resource_group
78
}

examples/key/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module "kms_key" {
4545

4646
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4747

48+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
4849
## Usage
4950

5051
To run this example you need to execute:

examples/key/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
terraform {
66
required_providers {
77
ibm = {
8-
source = "IBM-Cloud/ibm"
8+
source = "IBM-Cloud/ibm"
99
}
1010
}
1111
}

modules/instance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module "kms_instance" {
3838
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3939

4040

41+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
4142
## Usage
4243

4344
To run this example you need to execute:

modules/key/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ module "kms_key" {
1010
standard_key_type = var.standard_key_type
1111
force_delete = var.force_delete
1212
network_access_allowed = var.network_access_allowed
13+
policies = {
14+
rotation = {
15+
interval_month = 1
16+
}
17+
dual_auth_delete = {
18+
enabled = false
19+
}
20+
}
1321
}
1422
1523
```
@@ -28,6 +36,25 @@ module "kms_key" {
2836
| encrypted_nonce | Encrypted Nonce. Only for imported root key. |`string`| n/a | no |
2937
| iv_value | IV Value. Only for imported root key. |`string`| n/a | no |
3038
| expiration_date | Expination Date. |`string`| n/a | no |
39+
| policies | Set policies for a key. |`list(map)`| n/a | no |
40+
41+
## policies Inputs
42+
43+
| Name | Description | Type |Default |Required |
44+
|--------------------------|-------------------------------------------------------|:-------|:--------|:--------|
45+
| rotation | Specifies the key rotation time interval in months |`map(string)`| n/a| Atleast one of rotation/dual_auth_delete|
46+
| dual_auth_delete | Data associated with the dual authorization delete policy.|`map(string)`| n/a | Atleast one of rotation/dual_auth_delete|
47+
48+
## rotation Inputs
49+
50+
| Name | Description | Type |Default |Required |
51+
|--------------------------|----------------------------------------------------------------|:-------|:--------|:--------|
52+
| interval_month | Specifies the key rotation time interval in months |`int`| n/a | yes |
53+
## dual_auth_delete Inputs
54+
55+
| Name | Description | Type |Default |Required |
56+
|--------------------------|----------------------------------------------------------------|:-------|:--------|:--------|
57+
| enabled | If set to true, Key Protect enables a dual authorization policy on a single key. |`bool`| n/a | yes |
3158

3259
Note:
3360
* If the following attributes [`standard_key_type`, `force_delete`,`network_access_allowed`] are set to null then default values will be taken..
@@ -39,6 +66,7 @@ Note:
3966

4067
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4168

69+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
4270
## Usage
4371

4472
To run this example you need to execute:

modules/key/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,23 @@ resource "ibm_kms_key" "key" {
1313
encrypted_nonce = (var.encrypted_nonce != null ? var.encrypted_nonce : null)
1414
iv_value = (var.iv_value != null ? var.iv_value : null)
1515
expiration_date = (var.expiration_date != null ? var.expiration_date : null)
16+
dynamic "policies" {
17+
for_each = length(keys(var.policies)) == 0 ? [] : [var.policies]
18+
19+
content {
20+
dynamic "rotation" {
21+
for_each = length(keys(lookup(policies.value, "rotation", {}))) == 0 ? [] : [lookup(policies.value, "rotation", {})]
22+
23+
content {
24+
interval_month = lookup(rotation.value, "interval_month", null)
25+
}
26+
}
27+
dynamic "dual_auth_delete" {
28+
for_each = length(keys(lookup(policies.value, "dual_auth_delete", {}))) == 0 ? [] : [lookup(policies.value, "dual_auth_delete", {})]
29+
content {
30+
enabled = lookup(dual_auth_delete.value, "enabled", null)
31+
}
32+
}
33+
}
34+
}
1635
}

modules/key/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Copyright 2021 IBM
44
#########################################################################################
55
output "kms_key_output" {
6-
value=ibm_kms_key.key
6+
value = ibm_kms_key.key
77
}

0 commit comments

Comments
 (0)