Skip to content

Commit b2f88e8

Browse files
authored
feat: added support to connect an IBM Cloud Monitoring instance to the SCC Workload Protection instance using new input variable cloud_monitoring_instance_crn (#63)
1 parent 68d22fd commit b2f88e8

File tree

11 files changed

+163
-9
lines changed

11 files changed

+163
-9
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A module for provisioning an [IBM Cloud Security and Compliance Center Workload
1616
## Overview
1717
* [terraform-ibm-scc-workload-protection](#terraform-ibm-scc-workload-protection)
1818
* [Examples](./examples)
19+
* [Advanced example](./examples/advanced)
1920
* [Basic example](./examples/basic)
2021
* [Contributing](#contributing)
2122
<!-- END OVERVIEW HOOK -->
@@ -44,12 +45,13 @@ unless real values don't help users know what to change.
4445

4546
```hcl
4647
module "scc_wp" {
47-
source = "terraform-ibm-modules/scc-workload-protection/ibm"
48-
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
49-
name = "my-scc-wp-service"
50-
region = "us-south"
51-
resource_group_id = "65xxxxxxxxxxxxxxxa3fd"
52-
resource_key_tags = ["scc-wp-tag"]
48+
source = "terraform-ibm-modules/scc-workload-protection/ibm"
49+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
50+
name = "my-scc-wp-service"
51+
region = "us-south"
52+
resource_group_id = "65xxxxxxxxxxxxxxxa3fd"
53+
resource_key_tags = ["scc-wp-tag"]
54+
cloud_monitoring_instance_crn = "crn:v1:bluemix:public:sysdig-monitor:us-south:a/xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX:xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX::"
5355
}
5456
```
5557

@@ -109,6 +111,7 @@ No modules.
109111
| Name | Description | Type | Default | Required |
110112
|------|-------------|------|---------|:--------:|
111113
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the SCC WP instance created by the module. For more information, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial. | `list(string)` | `[]` | no |
114+
| <a name="input_cloud_monitoring_instance_crn"></a> [cloud\_monitoring\_instance\_crn](#input\_cloud\_monitoring\_instance\_crn) | The CRN of an IBM Cloud Monitoring instance to connect to the SCC Workload Protection instance. | `string` | `null` | no |
112115
| <a name="input_name"></a> [name](#input\_name) | A identifier used as a prefix when naming resources that will be provisioned. Must begin with a letter. | `string` | n/a | yes |
113116
| <a name="input_region"></a> [region](#input\_region) | IBM Cloud region where all resources will be deployed | `string` | `"us-south"` | no |
114117
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where resources will be provisioned. | `string` | n/a | yes |

examples/advanced/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Advanced example
2+
3+
An end-to-end example that uses the module's default variable values. This example uses the IBM Cloud terraform provider to:
4+
5+
- Create a new resource group if one is not passed in.
6+
- Create a new IBM Cloud monitoring instance.
7+
- Create a new Security and Compliance Center Workload Protection instance and connect it with IBM Cloud monitoring instance.

examples/advanced/main.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
########################################################################################################################
2+
# Resource group
3+
########################################################################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.1.4"
8+
# if an existing resource group is not set (null) create a new one using prefix
9+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
10+
existing_resource_group_name = var.resource_group
11+
}
12+
13+
########################################################################################################################
14+
# IBM Cloud monitoring instance
15+
########################################################################################################################
16+
17+
module "cloud_monitoring" {
18+
source = "terraform-ibm-modules/observability-instances/ibm//modules/cloud_monitoring"
19+
version = "2.11.0"
20+
resource_group_id = module.resource_group.resource_group_id
21+
region = var.region
22+
instance_name = "${var.prefix}-cm"
23+
}
24+
25+
########################################################################################################################
26+
# SCC WP instance
27+
########################################################################################################################
28+
29+
module "scc_wp" {
30+
source = "../.."
31+
name = var.prefix
32+
region = var.region
33+
resource_group_id = module.resource_group.resource_group_id
34+
resource_tags = var.resource_tags
35+
access_tags = var.access_tags
36+
cloud_monitoring_instance_crn = module.cloud_monitoring.crn
37+
}

examples/advanced/outputs.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
########################################################################################################################
2+
# Outputs
3+
########################################################################################################################
4+
5+
output "id" {
6+
description = "ID of created SCC WP instance."
7+
value = module.scc_wp.id
8+
}
9+
10+
output "crn" {
11+
description = "CRN of created SCC WP instance."
12+
value = module.scc_wp.crn
13+
}
14+
15+
output "name" {
16+
description = "Name of created SCC WP instance."
17+
value = module.scc_wp.name
18+
}
19+
20+
output "ingestion_endpoint" {
21+
description = "Ingestion endpoint."
22+
value = module.scc_wp.ingestion_endpoint
23+
sensitive = true
24+
}
25+
26+
output "api_endpoint" {
27+
description = "API endpoint."
28+
value = module.scc_wp.api_endpoint
29+
sensitive = true
30+
}
31+
32+
output "access_key" {
33+
description = "Workload Protection instance access key."
34+
value = module.scc_wp.access_key
35+
sensitive = true
36+
}
37+
38+
output "cloud_monitoring_crn" {
39+
description = "Workload Protection instance access key."
40+
value = module.cloud_monitoring.crn
41+
}

examples/advanced/provider.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
########################################################################################################################
2+
# Provider config
3+
########################################################################################################################
4+
5+
provider "ibm" {
6+
ibmcloud_api_key = var.ibmcloud_api_key
7+
region = var.region
8+
}

examples/advanced/variables.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
##############################################################################
3+
# Input Variables
4+
##############################################################################
5+
variable "ibmcloud_api_key" {
6+
description = "The IBM Cloud platform API key needed to deploy IAM enabled resources."
7+
type = string
8+
sensitive = true
9+
}
10+
11+
variable "prefix" {
12+
description = "Display name of the prefix for related resources"
13+
type = string
14+
default = "scc-wp-adv"
15+
}
16+
17+
variable "region" {
18+
description = "Name of the Region to deploy into"
19+
type = string
20+
default = "us-south"
21+
}
22+
23+
variable "resource_group" {
24+
type = string
25+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
26+
default = null
27+
}
28+
29+
variable "resource_tags" {
30+
type = list(string)
31+
description = "Optional list of tags to be added to created resources"
32+
default = []
33+
}
34+
35+
variable "access_tags" {
36+
type = list(string)
37+
description = "Optional list of access management tags to add to the SCC WP instance"
38+
default = []
39+
}

examples/advanced/version.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.3.0, <1.6.0"
3+
required_providers {
4+
# Use latest version of provider in non-basic examples to verify latest version works with module
5+
ibm = {
6+
source = "ibm-cloud/ibm"
7+
version = ">=1.61.0, <2.0.0"
8+
}
9+
}
10+
}

examples/basic/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ variable "resource_group" {
2626
default = null
2727
}
2828

29-
3029
variable "resource_tags" {
3130
type = list(string)
3231
description = "Optional list of tags to be added to created resources"

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ resource "ibm_resource_instance" "scc_wp" {
1515
plan = var.scc_wp_service_plan
1616
location = var.region
1717
tags = var.resource_tags
18+
parameters = {
19+
cloud_monitoring_connected_instance : var.cloud_monitoring_instance_crn
20+
}
1821
}
1922

2023
##############################################################################

tests/pr_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
// const resourceGroup = "geretain-test-resources"
15+
const advancedExampleDir = "examples/advanced"
1516
const basicExampleDir = "examples/basic"
1617

1718
// Define a struct with fields that match the structure of the YAML data
@@ -54,10 +55,10 @@ func TestRunBasicExample(t *testing.T) {
5455
assert.NotNil(t, output, "Expected some output")
5556
}
5657

57-
func TestRunBasicUpgradeExample(t *testing.T) {
58+
func TestRunAdvancedUpgradeExample(t *testing.T) {
5859
t.Parallel()
5960

60-
options := setupOptions(t, "scc-wp-upg", basicExampleDir)
61+
options := setupOptions(t, "scc-wp-upg", advancedExampleDir)
6162

6263
output, err := options.RunTestUpgrade()
6364
if !options.UpgradeTestSkipped {

0 commit comments

Comments
 (0)