Skip to content

Commit 716d387

Browse files
authored
feat: initial release (#1)
2 parents a44172f + 74c1d42 commit 716d387

26 files changed

+435
-168
lines changed

.github/settings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ repository:
1515
# By changing this field, you rename the repository.
1616

1717
# Uncomment this name property and set the name to the current repo name.
18-
# name: ""
18+
name: "terraform-ibm-key-protect-key"
1919

2020
# The description is displayed under the repository name on the
2121
# organization page and in the 'About' section of the repository.
2222

2323
# Uncomment this description property
2424
# and update the description to the current repo description.
25-
# description: ""
25+
description: "Module for creation of Key Protect keys"

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,49 @@ statement instead the previous block.
128128
<!-- BEGIN EXAMPLES HOOK -->
129129
## Examples
130130

131-
- [ Default example](examples/default)
132-
- [ Example that uses existing resources](examples/existing-resources)
133-
- [ Non default example](examples/non-default)
131+
- [ End to end example with default values](examples/default)
134132
<!-- END EXAMPLES HOOK -->
135133
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
136134
## Requirements
137135

138136
| Name | Version |
139137
|------|---------|
140138
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
139+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.45.0 |
141140

142141
## Modules
143142

144143
No modules.
145144

146145
## Resources
147146

148-
No resources.
147+
| Name | Type |
148+
|------|------|
149+
| [ibm_kms_key.key](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/kms_key) | resource |
150+
| [ibm_kms_key_policies.root_key_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/kms_key_policies) | resource |
151+
| [ibm_kms_key_policies.standard_key_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/kms_key_policies) | resource |
149152

150153
## Inputs
151154

152-
No inputs.
155+
| Name | Description | Type | Default | Required |
156+
|------|-------------|------|---------|:--------:|
157+
| <a name="input_dual_auth_delete_enabled"></a> [dual\_auth\_delete\_enabled](#input\_dual\_auth\_delete\_enabled) | Set as true to enable Dual Auth Delete | `bool` | `false` | no |
158+
| <a name="input_endpoint_type"></a> [endpoint\_type](#input\_endpoint\_type) | Endpoint to use when creating the Key | `string` | `"public"` | no |
159+
| <a name="input_force_delete"></a> [force\_delete](#input\_force\_delete) | Set as true to enable forcing deletion even if key is in use | `bool` | `false` | no |
160+
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Name to give the key | `string` | n/a | yes |
161+
| <a name="input_key_protect_instance_id"></a> [key\_protect\_instance\_id](#input\_key\_protect\_instance\_id) | ID of Key Protect Instance | `string` | n/a | yes |
162+
| <a name="input_key_protect_key_ring_id"></a> [key\_protect\_key\_ring\_id](#input\_key\_protect\_key\_ring\_id) | ID of Key Ring where key is assigned | `string` | `"default"` | no |
163+
| <a name="input_rotation_interval_month"></a> [rotation\_interval\_month](#input\_rotation\_interval\_month) | Interval in months to rotate the Key | `number` | `1` | no |
164+
| <a name="input_standard_key"></a> [standard\_key](#input\_standard\_key) | Set as true for Standard Key, false for Root Key | `bool` | `false` | no |
153165

154166
## Outputs
155167

156-
No outputs.
168+
| Name | Description |
169+
|------|-------------|
170+
| <a name="output_crn"></a> [crn](#output\_crn) | Key CRN |
171+
| <a name="output_dual_auth_delete"></a> [dual\_auth\_delete](#output\_dual\_auth\_delete) | Is Dual Auth Delete Enabled |
172+
| <a name="output_key_id"></a> [key\_id](#output\_key\_id) | Key ID |
173+
| <a name="output_rotation_interval_month"></a> [rotation\_interval\_month](#output\_rotation\_interval\_month) | Month Interval for Rotation |
157174
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
158175
<!-- BEGIN CONTRIBUTING HOOK -->
159176

examples/default/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Default example
1+
# End to end example with default values
22

33
An end-to-end example that uses the module's default variable values.
44
This example uses the IBM Cloud terraform provider to:
55
- Create a new resource group if one is not passed in.
6-
- Create a new VPC in the resource group and region provided.
6+
- Create a new Key Protect instance in the Resource Group.
7+
- Create a new Root Key in the Key Protect instance.
8+
- Create a new Standard Key in the Key Protect instance.
79

810
<!-- Add your example and link to it from the module's main readme file. -->

examples/default/main.tf

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,26 @@ module "resource_group" {
1010
}
1111

1212
##############################################################################
13-
# VPC
13+
# Key Protect module
1414
##############################################################################
1515

16-
resource "ibm_is_vpc" "vpc" {
17-
name = "${var.prefix}-vpc"
18-
resource_group = module.resource_group.resource_group_id
19-
tags = var.resource_tags
16+
module "key_protect_module" {
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-key-protect.git?ref=v1.0.0"
18+
key_protect_name = "${var.prefix}-key-protect"
19+
resource_group_id = module.resource_group.resource_group_id
20+
region = var.region
21+
tags = var.resource_tags
22+
}
23+
24+
module "key_protect_root_key" {
25+
source = "../.."
26+
key_protect_instance_id = module.key_protect_module.key_protect_guid
27+
key_name = "${var.prefix}-root-key"
28+
}
29+
30+
module "key_protect_standard_key" {
31+
source = "../.."
32+
key_protect_instance_id = module.key_protect_module.key_protect_guid
33+
key_name = "${var.prefix}-standard-key"
34+
standard_key = true
2035
}

examples/default/outputs.tf

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@
22
# Outputs
33
##############################################################################
44

5-
output "vpc_id" {
6-
description = "ID of VPC created"
7-
value = ibm_is_vpc.vpc.id
5+
output "instance_id" {
6+
description = "Key Protect Instance ID"
7+
value = module.key_protect_module.key_protect_guid
8+
}
9+
10+
output "root_key_id" {
11+
description = "Key Protect Key ID"
12+
value = module.key_protect_root_key.key_id
13+
}
14+
15+
output "root_key_rotation_interval_month" {
16+
description = "Month Interval for Rotation"
17+
value = module.key_protect_root_key.rotation_interval_month
18+
}
19+
20+
output "root_key_dual_auth_delete_enabled" {
21+
description = "Is Dual Auth Delete Enabled"
22+
value = module.key_protect_root_key.dual_auth_delete
23+
}
24+
25+
output "standard_key_id" {
26+
description = "Key Protect Key ID"
27+
value = module.key_protect_standard_key.key_id
28+
}
29+
30+
output "standard_key_rotation_interval_month" {
31+
description = "Month Interval for Rotation"
32+
value = module.key_protect_standard_key.rotation_interval_month
33+
}
34+
35+
output "standard_key_dual_auth_delete_enabled" {
36+
description = "Is Dual Auth Delete Enabled"
37+
value = module.key_protect_standard_key.dual_auth_delete
838
}
939

1040
output "resource_group_name" {

examples/default/provider.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,18 @@ provider "ibm" {
22
ibmcloud_api_key = var.ibmcloud_api_key
33
region = var.region
44
}
5+
6+
data "ibm_iam_auth_token" "token_data" {
7+
}
8+
9+
provider "restapi" {
10+
uri = "https:"
11+
write_returns_object = false
12+
create_returns_object = false
13+
debug = false # set to true to show detailed logs, but use carefully as it might print sensitive values.
14+
headers = {
15+
Authorization = data.ibm_iam_auth_token.token_data.iam_access_token
16+
Bluemix-Instance = module.key_protect_module.key_protect_guid
17+
Content-Type = "application/vnd.ibm.kms.policy+json"
18+
}
19+
}

examples/default/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ variable "region" {
1313
variable "prefix" {
1414
type = string
1515
description = "Prefix to append to all resources created by this example"
16-
default = "terraform"
16+
default = "kp-key"
1717
}
1818

1919
variable "resource_group" {

examples/default/version.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ terraform {
66
source = "IBM-Cloud/ibm"
77
version = "1.45.0"
88
}
9+
restapi = {
10+
source = "Mastercard/restapi"
11+
version = "1.17.0"
12+
}
913
}
1014
}

examples/existing-resources/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/existing-resources/main.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)