Skip to content

Commit 9ba1783

Browse files
fix: onboard module to IBM Cloud module registry (#491)
1 parent 58562ae commit 9ba1783

21 files changed

+130
-34
lines changed

.secrets.baseline

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-06-07T10:48:18Z",
6+
"generated_at": "2023-11-22T17:09:56Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -86,6 +86,16 @@
8686
"type": "Secret Keyword",
8787
"verified_result": null
8888
}
89+
],
90+
"ibm_catalog.json": [
91+
{
92+
"hashed_secret": "2a66dd6b2184e0722c4f448eaac79a1897987a30",
93+
"is_secret": false,
94+
"is_verified": false,
95+
"line_number": 22,
96+
"type": "Secret Keyword",
97+
"verified_result": null
98+
}
8999
]
90100
},
91101
"version": "0.13.1+ibm.61.dss",

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ provider "ibm" {
1919
2020
# KMS root key
2121
module "kms_root_key" {
22-
source = "terraform-ibm-modules/kms-key/ibm"
23-
version = "latest" # Replace "latest" with a release version to lock into a specific release
24-
kms_instance_id = ibm_resource_instance.kms_instance.guid
25-
key_name = "my-root-key"
22+
source = "terraform-ibm-modules/kms-key/ibm"
23+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
24+
kms_instance_id = "XXxxXXxx-xxxx-XXXX-xxxx-XXxxXXxx"
25+
key_name = "my-root-key"
2626
}
2727
2828
# KMS standard key
2929
module "kms_standard_key" {
30-
source = "terraform-ibm-modules/kms-key/ibm"
31-
version = "latest" # Replace "latest" with a release version to lock into a specific release
32-
kms_instance_id = ibm_resource_instance.kms_instance.guid
33-
key_name = "my-standard-key"
34-
standard_key = true
30+
source = "terraform-ibm-modules/kms-key/ibm"
31+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
32+
kms_instance_id = "XXxxXXxx-xxxx-XXXX-xxxx-XXxxXXxx"
33+
key_name = "my-standard-key"
34+
standard_key = true
3535
}
3636
```
3737

@@ -49,8 +49,8 @@ You need the following permissions to run this module.
4949
<!-- BEGIN EXAMPLES HOOK -->
5050
## Examples
5151

52-
- [ End to end example with default values](examples/default)
53-
- [ Example that uses existing KMS instance](examples/existing-kms)
52+
- [ Basic example](examples/basic)
53+
- [ Complete example](examples/complete)
5454
<!-- END EXAMPLES HOOK -->
5555
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5656
### Requirements

cra-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# More info about this file at https://github.com/terraform-ibm-modules/common-pipeline-assets/blob/main/.github/workflows/terraform-test-pipeline.md#cra-config-yaml
22
version: "v1"
33
CRA_TARGETS:
4-
- CRA_TARGET: "examples/default" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
4+
- CRA_TARGET: "examples/complete" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
55
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
66
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
77
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.

examples/basic/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Basic example
2+
3+
A simple example that shows how to create a standard and a root key in an existing IBM Key Management Service (KMS) instance.
4+
5+
The following resources are provisioned by this example:
6+
- Create a root key in the existing KMS instance.
7+
- Create a standard key in the existing KMS instance.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ibmcloud_api_key": $VALIDATION_APIKEY,
3+
"existing_kms_instance_guid": $HPCS_US_SOUTH_GUID,
4+
"prefix": $PREFIX
5+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/complete/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Complete example
2+
3+
A complete example showing how to provision a Key Protect instance, a root key and a standard key.
4+
5+
The following resources are provisioned by this example:
6+
- A new resource group, if an existing one is not passed in.
7+
- An IBM Key Protect instance.
8+
- A Root Key in the KMS instance.
9+
- A Standard Key in the KMS instance.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ibmcloud_api_key": $VALIDATION_APIKEY,
3+
"region": "us-south",
4+
"resource_tags": $TAGS,
5+
"prefix": $PREFIX
6+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/default/README.md

-8
This file was deleted.

examples/existing-kms/README.md

-6
This file was deleted.

ibm_catalog.json

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"products": [
3+
{
4+
"name": "terraform-ibm-kms-key",
5+
"label": "KMS Key module",
6+
"product_kind": "module",
7+
"tags": [
8+
"dev_ops",
9+
"target_terraform",
10+
"terraform",
11+
"module"
12+
],
13+
"keywords": [
14+
"terraform",
15+
"key protect",
16+
"hpcs",
17+
"keys",
18+
"encryption",
19+
"kms"
20+
],
21+
"short_description": "Terraform module to create a standard or root key in an IBM Key Management Service (KMS).",
22+
"long_description": "Use this module to create a standard or root key in an existing key ring and IBM Key Management Services (KMS) instance. The KMS can be IBM Key Protect or IBM Cloud Hyper Protect Crypto Services(HPCS) instance. You can specify rotation and deletion policies for the keys.\n\n### Usage\n```hcl\nprovider \"ibm\" {\n ibmcloud_api_key = \"XXXXXXXXXX\"\n # Must be the same region the KMS instance is in\n region = \"us-south\"\n}\n\n# KMS root key\nmodule \"kms_root_key\" {\n # Replace \"X.X.X\" with a release version to lock into a specific release\n source. = \"https://cm.globalcatalog.cloud.ibm.com/api/v1-beta/offering/source?archive=tgz&kind=terraform&name=terraform-ibm-kms-key&version=X.X.X\"\n kms_instance_id = \"XXxxXXxx-xxxx-XXXX-xxxx-XXxxXXxx\"\n key_name = \"my-root-key\"\n}\n\n# KMS standard key\nmodule \"kms_standard_key\" {\n # Replace \"X.X.X\" with a release version to lock into a specific release\n source. = \"https://cm.globalcatalog.cloud.ibm.com/api/v1-beta/offering/source?archive=tgz&kind=terraform&name=terraform-ibm-kms-key&version=X.X.X\"\n kms_instance_id = \"XXxxXXxx-xxxx-XXXX-xxxx-XXxxXXxx\"\n key_name = \"my-standard-key\"\n standard_key = true\n}\n```",
23+
"offering_docs_url": "https://github.com/terraform-ibm-modules/terraform-ibm-kms-key/blob/main/README.md",
24+
"offering_icon_url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/key_protect_icon.svg",
25+
"features": [
26+
{
27+
"title": "Create a KMS key",
28+
"description": "Create a standard or root key in an existing IBM KMS instance key ring."
29+
},
30+
{
31+
"title": "Create a KMS key policy",
32+
"description": "Create a key policy for a standard or root key in an IBM KMS instance."
33+
}
34+
],
35+
"flavors": [
36+
{
37+
"label": "Basic",
38+
"name": "basic",
39+
"working_directory": "examples/basic",
40+
"architecture": {
41+
"diagrams": [
42+
{
43+
"diagram": {
44+
"caption": "Basic example",
45+
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/ModuleExampleDiagram.svg",
46+
"type": "image/svg+xml"
47+
},
48+
"description": "A simple example that shows how to create a standard and a root key in an existing IBM Key Management Service (KMS) instance."
49+
}
50+
]
51+
}
52+
},
53+
{
54+
"label": "Complete",
55+
"name": "complete",
56+
"working_directory": "examples/complete",
57+
"architecture": {
58+
"diagrams": [
59+
{
60+
"diagram": {
61+
"caption": "Complete example",
62+
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/ModuleExampleDiagram.svg",
63+
"type": "image/svg+xml"
64+
},
65+
"description": "A complete example that shows how to provision a Key Protect instance, a root key and a standard key."
66+
}
67+
]
68+
}
69+
}
70+
]
71+
}
72+
]
73+
}

tests/pr_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
// Use existing resource group for tests
1515
const resourceGroup = "geretain-test-key-protect-key"
16-
const defaultExampleTerraformDir = "examples/default"
17-
const existingKmsExampleTerraformDir = "examples/existing-kms"
16+
const completeExampleTerraformDir = "examples/complete"
17+
const basicExampleTerraformDir = "examples/basic"
1818

1919
// Define a struct with fields that match the structure of the YAML data
2020
const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml"
@@ -36,15 +36,15 @@ func TestMain(m *testing.M) {
3636
func setupOptions(t *testing.T, prefix string) *testhelper.TestOptions {
3737
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
3838
Testing: t,
39-
TerraformDir: defaultExampleTerraformDir,
39+
TerraformDir: completeExampleTerraformDir,
4040
Prefix: prefix,
4141
ResourceGroup: resourceGroup,
4242
})
4343

4444
return options
4545
}
4646

47-
func TestRunDefaultExample(t *testing.T) {
47+
func TestRunCompleteExample(t *testing.T) {
4848
t.Parallel()
4949

5050
options := setupOptions(t, "kms-key")
@@ -53,12 +53,12 @@ func TestRunDefaultExample(t *testing.T) {
5353
assert.NotNil(t, output, "Expected some output")
5454
}
5555

56-
func TestRunExistingKMSExample(t *testing.T) {
56+
func TestRunBasicExample(t *testing.T) {
5757
t.Parallel()
5858

5959
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
6060
Testing: t,
61-
TerraformDir: existingKmsExampleTerraformDir,
61+
TerraformDir: basicExampleTerraformDir,
6262
Prefix: "hpcs",
6363
TerraformVars: map[string]interface{}{
6464
"existing_kms_instance_guid": permanentResources["hpcs_south"],
@@ -70,7 +70,7 @@ func TestRunExistingKMSExample(t *testing.T) {
7070
assert.NotNil(t, output, "Expected some output")
7171
}
7272

73-
func TestRunUpgrade(t *testing.T) {
73+
func TestRunCompleteUpgrade(t *testing.T) {
7474
t.Parallel()
7575

7676
options := setupOptions(t, "kms-key-upg")

0 commit comments

Comments
 (0)