Skip to content

Commit 6890e8d

Browse files
committed
fix(deps): update DA dependencies + example / tests cleanup
1 parent 3df8ac6 commit 6890e8d

File tree

14 files changed

+159
-385
lines changed

14 files changed

+159
-385
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ This module is used to provision and configure an IBM Cloud [Secrets Manager](ht
1919
* [fscloud](./modules/fscloud)
2020
* [secrets](./modules/secrets)
2121
* [Examples](./examples)
22+
* [Advanced example](./examples/advanced)
2223
* [Basic example](./examples/basic)
23-
* [Complete example with BYOK encryption](./examples/complete)
2424
* [Financial Services Cloud profile example with KYOK encryption](./examples/fscloud)
2525
* [Contributing](#contributing)
2626
<!-- END OVERVIEW HOOK -->

examples/advanced/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Advanced example
2+
3+
An example that configures:
4+
5+
- A new resource group if one is not passed in.
6+
- A new Key Protect instance and root key
7+
- A new Event Notifications instance
8+
- An s2s auth policy to allow Secrets Manager to manage Event Notifications service credentials
9+
- A new Secretes Manager instance
10+
- A new secret group with a new Event Notifications service credential secret and an arbitrary secret
11+
- A new arbitrary secret in the default secret group
12+
- A sample code engine project that builds a code engine job and outputs User IBM Cloud IAM API Keys
13+
- A custom credential engine using the code engine project
14+
- A custom credential secret

examples/complete/main.tf renamed to examples/advanced/main.tf

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##############################################################################
2+
# Resource group
3+
##############################################################################
4+
15
module "resource_group" {
26
source = "terraform-ibm-modules/resource-group/ibm"
37
version = "1.3.0"
@@ -6,6 +10,10 @@ module "resource_group" {
610
existing_resource_group_name = var.resource_group
711
}
812

13+
##############################################################################
14+
# Key Protect instance and root key
15+
##############################################################################
16+
917
module "key_protect" {
1018
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
1119
version = "5.1.25"
@@ -25,7 +33,11 @@ module "key_protect" {
2533
]
2634
}
2735

28-
module "event_notification" {
36+
##############################################################################
37+
# Event Notifications
38+
##############################################################################
39+
40+
module "event_notifications" {
2941
source = "terraform-ibm-modules/event-notifications/ibm"
3042
version = "2.7.0"
3143
resource_group_id = module.resource_group.resource_group_id
@@ -35,14 +47,13 @@ module "event_notification" {
3547
region = var.en_region
3648
}
3749

50+
# s2s auth policy required for Secrets Manager to manage Event Notifications service credentials
3851
resource "ibm_iam_authorization_policy" "en_policy" {
3952
source_service_name = "secrets-manager"
4053
roles = ["Key Manager"]
4154
target_service_name = "event-notifications"
42-
target_resource_instance_id = module.event_notification.guid
43-
description = "Allow the Secret manager Key Manager role access to event-notifications with guid ${module.event_notification.guid}."
44-
# Scope of policy now includes the key, so ensure to create new policy before
45-
# destroying old one to prevent any disruption to every day services.
55+
target_resource_instance_id = module.event_notifications.guid
56+
description = "Grant Secret Manager a 'Key Manager' role to the Event Notifications instance ${module.event_notifications.guid} for managing service credentials."
4657
lifecycle {
4758
create_before_destroy = true
4859
}
@@ -53,6 +64,10 @@ resource "time_sleep" "wait_for_en_policy" {
5364
create_duration = "30s"
5465
}
5566

67+
##############################################################################
68+
# Secrets Manager
69+
##############################################################################
70+
5671
module "secrets_manager" {
5772
depends_on = [time_sleep.wait_for_en_policy]
5873
source = "../.."
@@ -65,30 +80,29 @@ module "secrets_manager" {
6580
is_hpcs_key = false
6681
kms_key_crn = module.key_protect.keys["${var.prefix}-sm.${var.prefix}-sm-key"].crn
6782
enable_event_notification = true
68-
existing_en_instance_crn = module.event_notification.crn
83+
existing_en_instance_crn = module.event_notifications.crn
6984
secrets = [
85+
# Example creating new secrets group with secrets in it
7086
{
7187
secret_group_name = "${var.prefix}-secret-group"
72-
secrets = [{
73-
secret_name = "${var.prefix}-kp-key-crn"
74-
secret_type = "arbitrary"
75-
secret_payload_password = module.key_protect.keys["${var.prefix}-sm.${var.prefix}-sm-key"].crn
76-
},
88+
secrets = [
89+
# Example creating Event Notifications service credential secret
7790
{
78-
# Arbitrary service credential for source service event notifications, with role Event-Notification-Publisher
7991
secret_name = "${var.prefix}-service-credential"
8092
secret_type = "service_credentials" #checkov:skip=CKV_SECRET_6
81-
secret_description = "Created by secrets-manager-module complete example"
82-
service_credentials_source_service_crn = module.event_notification.crn
93+
secret_description = "Created by secrets-manager-module advanced example"
94+
service_credentials_source_service_crn = module.event_notifications.crn
8395
service_credentials_source_service_role_crn = "crn:v1:bluemix:public:event-notifications::::serviceRole:Event-Notification-Publisher"
8496
},
97+
# Example creating arbitrary secret
8598
{
86-
secret_name = "${var.prefix}-custom-service-credential"
99+
secret_name = "${var.prefix}-arbitrary-example"
87100
secret_type = "arbitrary"
88101
secret_payload_password = var.ibmcloud_api_key
89102
}
90103
]
91104
},
105+
# Example creating secret in existing secret group
92106
{
93107
secret_group_name = "default"
94108
existing_secret_group = true
@@ -103,18 +117,19 @@ module "secrets_manager" {
103117
}
104118

105119
##############################################################################
106-
# Code Engine Project
120+
# Code Engine configuration
121+
# (required to use create a custom credential)
107122
##############################################################################
123+
124+
# Create new code engine project
108125
module "code_engine_project" {
109126
source = "terraform-ibm-modules/code-engine/ibm//modules/project"
110127
version = "4.5.13"
111128
name = "${var.prefix}-project"
112129
resource_group_id = module.resource_group.resource_group_id
113130
}
114131

115-
##############################################################################
116-
# Code Engine Secret
117-
##############################################################################
132+
# Create new code engine secret
118133
locals {
119134
registry_hostname = "private.de.icr.io"
120135
output_image = "${local.registry_hostname}/${resource.ibm_cr_namespace.rg_namespace.name}/custom-engine-job"
@@ -133,19 +148,13 @@ module "code_engine_secret" {
133148
}
134149
}
135150

136-
##############################################################################
137-
# Container Registry Namespace
138-
##############################################################################
151+
# Create new Container Registry namespace
139152
resource "ibm_cr_namespace" "rg_namespace" {
140153
name = "${var.prefix}-crn"
141154
resource_group_id = module.resource_group.resource_group_id
142155
}
143156

144-
##############################################################################
145-
# Code Engine Build
146-
##############################################################################
147-
148-
# For example the region is hardcoded to us-south in order to hardcode the output image and region for creating Code Engine Project and build
157+
# Build example Go application in Code Engine project which dynamically generates User IBM Cloud IAM API Keys
149158
module "code_engine_build" {
150159
source = "terraform-ibm-modules/code-engine/ibm//modules/build"
151160
version = "4.5.13"
@@ -161,10 +170,7 @@ module "code_engine_build" {
161170
output_image = local.output_image
162171
}
163172

164-
##############################################################################
165-
# Code Engine Job
166-
##############################################################################
167-
173+
# Pull the sample job config from github
168174
data "http" "job_config" {
169175
url = "https://raw.githubusercontent.com/IBM/secrets-manager-custom-credentials-providers/refs/heads/main/ibmcloud-iam-user-apikey-provider-go/job_config.json"
170176
request_headers = {
@@ -176,6 +182,7 @@ locals {
176182
job_env_variables = jsondecode(data.http.job_config.response_body).job_env_variables
177183
}
178184

185+
# Run the Code Engine job
179186
module "code_engine_job" {
180187
depends_on = [module.code_engine_build]
181188
source = "terraform-ibm-modules/code-engine/ibm//modules/job"
@@ -194,7 +201,7 @@ module "code_engine_job" {
194201
}
195202

196203
##############################################################################
197-
# Custom Credential Engine and secret
204+
# Create Custom Credential engine
198205
##############################################################################
199206

200207
module "custom_credential_engine" {
@@ -213,8 +220,12 @@ module "custom_credential_engine" {
213220
iam_credential_secret_name = "${var.prefix}-test-iam-secret"
214221
}
215222

216-
# Currently the main module cannot be called again as some of the count for resources depends on a computable input existing_en_instance_crn which will give error if the value is not available during planning
217-
# As a workaround the secret manager secret is directly being created via module call
223+
##############################################################################
224+
# Create Custom Credential secret
225+
# (using secrets-manager-secret to create the custom credential secret as it
226+
# can only be done after the Custom Credential engine is configured)
227+
##############################################################################
228+
218229
module "secret_manager_custom_credential" {
219230
depends_on = [module.secrets_manager, module.custom_credential_engine]
220231
source = "terraform-ibm-modules/secrets-manager-secret/ibm"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/complete/README.md

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

examples/fscloud/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
An end-to-end example that uses the [Profile for IBM Cloud Framework for Financial Services](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/tree/main/modules/fscloud) to deploy a private only Secrets-Manager instance with KYOK encryption
44

5-
This examples handles the provisioning of Secrets-Manager instance, the IAM engine configuration in the recently created instance and a context-based restriction (CBR) rule to only allow Secret Manager to be accessible from within the VPC..
6-
7-
Only private service endpoints are enabled, public are disabled. Secrets Manager instances that are private only do not offer a UI management experience.
8-
The example uses the IBM Cloud Terraform provider to create the following infrastructure:
5+
The example creates the following infrastructure:
96

107
- A resource group, if one is not passed in.
11-
- A sample virtual private cloud (VPC).
12-
- A sample event notification service.
13-
- A secrets manager instance.
14-
- A context-based restriction (CBR) rule to only allow Secrets Manager to be accessible from within the VPC.
8+
- A CBR zone for Schematics
9+
- An Event Notifications instance.
10+
- A Secrets Manager instance.
11+
- A context-based restriction (CBR) rule to only allow Secrets Manager to be accessible from the Schematics service.
1512

1613
:exclamation: **Important:** In this example, only the IBM Secrets Manager instance complies with the IBM Cloud Framework for Financial Services. Other parts of the infrastructure do not necessarily comply.
1714

0 commit comments

Comments
 (0)