Skip to content

Commit

Permalink
fix: onboarding module to IBM Cloud module registry (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatagarwal-ibm committed Nov 22, 2023
1 parent 0732443 commit 9bcc7e2
Show file tree
Hide file tree
Showing 21 changed files with 115 additions and 24 deletions.
12 changes: 11 additions & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.sum|^.secrets.baseline$",
"lines": null
},
"generated_at": "2023-06-10T00:13:05Z",
"generated_at": "2023-11-22T11:03:19Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -86,6 +86,16 @@
"type": "Secret Keyword",
"verified_result": null
}
],
"ibm_catalog.json": [
{
"hashed_secret": "2a66dd6b2184e0722c4f448eaac79a1897987a30",
"is_secret": false,
"is_verified": false,
"line_number": 21,
"type": "Secret Keyword",
"verified_result": null
}
]
},
"version": "0.13.1+ibm.61.dss",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ You need the following permissions to run this module.
<!-- BEGIN EXAMPLES HOOK -->
## Examples

- [ End to end example with default values](examples/default)
- [ An example that uses existing KMS](examples/existing-kms)
- [ Basic example](examples/basic)
- [ Complete example](examples/complete)
<!-- END EXAMPLES HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements
Expand Down
2 changes: 1 addition & 1 deletion cra-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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
version: "v1"
CRA_TARGETS:
- CRA_TARGET: "examples/default" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
- CRA_TARGET: "examples/complete" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
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`
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
6 changes: 6 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Basic example

A simple example that shows how to create a key ring in an existing IBM Key Management Service (KMS) instance.

The following resources are provisioned by this example:
- A key ring in an existing Key Management Service (KMS) instance.
5 changes: 5 additions & 0 deletions examples/basic/catalogValidationValues.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ibmcloud_api_key": $VALIDATION_APIKEY,
"existing_kms_instance_guid": $HPCS_US_SOUTH_GUID,
"prefix": $PREFIX
}
2 changes: 0 additions & 2 deletions examples/existing-kms/main.tf → examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


##############################################################################
# Key Ring module
##############################################################################
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Complete example

A complete example showing how to provision a Key Protect instance, a new key ring, and a new key.

The following resources are provisioned by this example:
- A new resource group, if an existing one is not passed in.
- An IBM Key Protect instance.
- A key ring in the IBM Key Protect instance.
- A key within the key ring.
6 changes: 6 additions & 0 deletions examples/complete/catalogValidationValues.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ibmcloud_api_key": $VALIDATION_APIKEY,
"region": "us-south",
"resource_tags": $TAGS,
"prefix": $PREFIX
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions examples/default/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions examples/existing-kms/README.md

This file was deleted.

68 changes: 68 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"products": [
{
"name": "terraform-ibm-kms-key-ring",
"label": "KMS Key Ring module",
"product_kind": "module",
"tags": [
"dev_ops",
"target_terraform",
"terraform",
"module"
],
"keywords": [
"terraform",
"key protect",
"hpcs",
"key ring",
"encryption"
],
"short_description": "Terraform module to create a key ring in an IBM Key Management Service",
"long_description": "Use this module to create a key ring to help organize keys in an IBM Key Management Services (KMS) instance. The KMS can be IBM Key Protect or IBM Cloud Hyper Protect Crypto Services(HPCS) instance. For more information, about key rings, see [creating key rings in Key Protect](https://cloud.ibm.com/docs/key-protect?topic=key-protect-grouping-keys#create-key-ring-api) and [managing key rings in HPCS](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-managing-key-rings&interface=ui).\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\nmodule \"kms_key_ring\" {\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-ring&version=X.X.X\"\n instance_id = \"XXxxXXxx-xxxx-XXXX-xxxx-XXxxXXxx\"\n key_ring_id = \"my-key-ring\"\n}\n```",
"offering_docs_url": "https://github.com/terraform-ibm-modules/terraform-ibm-key-protect/blob/main/README.md",
"offering_icon_url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/key_protect_icon.svg",
"features": [
{
"title": "Create a KMS key ring",
"description": "Create a key ring in an IBM Key Management Service (KMS) instance."
}
],
"flavors": [
{
"label": "Basic",
"name": "basic",
"working_directory": "examples/basic",
"architecture": {
"diagrams": [
{
"diagram": {
"caption": "Basic example",
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/ModuleExampleDiagram.svg",
"type": "image/svg+xml"
},
"description": "A simple example that shows how to create a key ring in an existing IBM Hyper Protect Crypto Service (HPCS) instance."
}
]
}
},
{
"label": "Complete",
"name": "complete",
"working_directory": "examples/complete",
"architecture": {
"diagrams": [
{
"diagram": {
"caption": "Complete example",
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/documentation/main/icons/ModuleExampleDiagram.svg",
"type": "image/svg+xml"
},
"description": "A complete example showing how to provision a Key Protect instance, a new key ring, and a new key."
}
]
}
}
]
}
]
}
14 changes: 7 additions & 7 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

// Use existing resource group for tests
const resourceGroup = "geretain-test-key-protect-key-ring"
const defaultExampleTerraformDir = "examples/default"
const existingKmsExampleTerraformDir = "examples/existing-kms"
const completeExampleTerraformDir = "examples/complete"
const basicExampleTerraformDir = "examples/basic"

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

return options
}

func TestRunDefaultExample(t *testing.T) {
func TestRunCompleteExample(t *testing.T) {
t.Parallel()

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

func TestRunExistingKMSExample(t *testing.T) {
func TestRunBasicExample(t *testing.T) {
t.Parallel()

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

func TestRunUpgrade(t *testing.T) {
func TestRunCompleteExampleUpgrade(t *testing.T) {
t.Parallel()

options := setupOptions(t, "kms-key-ring-upg")
Expand Down

0 comments on commit 9bcc7e2

Please sign in to comment.