Skip to content

Commit 778b248

Browse files
authored
feat: Add support for Cloud Security Posture Management (CSPM) (#225)
1 parent 62e22f4 commit 778b248

File tree

30 files changed

+782
-291
lines changed

30 files changed

+782
-291
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ unless real values don't help users know what to change.
4444
-->
4545

4646
```hcl
47+
data "ibm_iam_auth_token" "auth_token" {}
48+
49+
provider "restapi" {
50+
uri = "https://resource-controller.cloud.ibm.com" # https://private.resource-controller.cloud.ibm.com for private
51+
headers = {
52+
Authorization = data.ibm_iam_auth_token.auth_token.iam_access_token
53+
}
54+
write_returns_object = true
55+
}
56+
4757
module "scc_wp" {
4858
source = "terraform-ibm-modules/scc-workload-protection/ibm"
4959
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
@@ -52,9 +62,14 @@ module "scc_wp" {
5262
resource_group_id = "65xxxxxxxxxxxxxxxa3fd"
5363
resource_key_tags = ["scc-wp-tag"]
5464
cloud_monitoring_instance_crn = "crn:v1:bluemix:public:sysdig-monitor:us-south:a/xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX:xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX::"
65+
app_config_crn = "crn:v1:bluemix:public:apprap:us-south:a/xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX:xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX::"
5566
}
5667
```
5768

69+
### Known issues
70+
#### restapi_object.enable_cspm resource always identified for creation
71+
There is currently a [known issue](https://github.com/terraform-ibm-modules/terraform-ibm-scc-workload-protection/issues/243) where you will always see the `restapi_object.enable_cspm` resource included in the terraform plan for creation, even after it has already been applied. It is safe to proceed with this apply and will be a no-op if the resource has already been applied.
72+
5873
### Required IAM access policies
5974

6075
<!-- PERMISSIONS REQUIRED TO RUN MODULE
@@ -88,12 +103,14 @@ statement instead the previous block.
88103
|------|---------|
89104
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
90105
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0, <2.0.0 |
106+
| <a name="requirement_restapi"></a> [restapi](#requirement\_restapi) | >=1.20.0, <2.0.0 |
91107

92108
### Modules
93109

94110
| Name | Source | Version |
95111
|------|--------|---------|
96112
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.31.0 |
113+
| <a name="module_trusted_profile_scc_wp"></a> [trusted\_profile\_scc\_wp](#module\_trusted\_profile\_scc\_wp) | terraform-ibm-modules/trusted-profile/ibm | 3.0.0 |
97114

98115
### Resources
99116

@@ -102,27 +119,32 @@ statement instead the previous block.
102119
| [ibm_resource_instance.scc_wp](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_instance) | resource |
103120
| [ibm_resource_key.scc_wp_resource_key](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_key) | resource |
104121
| [ibm_resource_tag.scc_wp_access_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
122+
| [restapi_object.cspm](https://registry.terraform.io/providers/Mastercard/restapi/latest/docs/resources/object) | resource |
105123

106124
### Inputs
107125

108126
| Name | Description | Type | Default | Required |
109127
|------|-------------|------|---------|:--------:|
110128
| <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 |
129+
| <a name="input_app_config_crn"></a> [app\_config\_crn](#input\_app\_config\_crn) | The CRN of an existing App Config instance to use with the SCC Workload Protection instance. Required if `cspm_enabled` is true. NOTE: Ensure the App Config instance has configuration aggregator enabled. | `string` | `null` | no |
111130
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restriction rules to create. | <pre>list(object({<br/> description = string<br/> account_id = string<br/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })), [])<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> }))</pre> | `[]` | no |
112131
| <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 |
132+
| <a name="input_cspm_enabled"></a> [cspm\_enabled](#input\_cspm\_enabled) | Enable Cloud Security Posture Management (CSPM) for the Workload Protection instance. This will create a trusted profile associated with the SCC Workload Protection instance that has viewer / reader access to the App Config service and viewer access to the Enterprise service. [Learn more](https://cloud.ibm.com/docs/workload-protection?topic=workload-protection-about). | `bool` | `true` | no |
113133
| <a name="input_name"></a> [name](#input\_name) | The name to give the SCC Workload Protection instance that will be provisioned by this module. | `string` | n/a | yes |
114134
| <a name="input_region"></a> [region](#input\_region) | IBM Cloud region where all resources will be deployed | `string` | `"us-south"` | no |
115135
| <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 |
116136
| <a name="input_resource_key_name"></a> [resource\_key\_name](#input\_resource\_key\_name) | The name to give the IBM Cloud SCC WP resource key. | `string` | `"SCCWPManagerKey"` | no |
117137
| <a name="input_resource_key_tags"></a> [resource\_key\_tags](#input\_resource\_key\_tags) | Tags associated with the IBM Cloud SCC WP resource key. | `list(string)` | `[]` | no |
118138
| <a name="input_resource_tags"></a> [resource\_tags](#input\_resource\_tags) | Optional list of tags to be added to created SCC WP instance. | `list(string)` | `[]` | no |
139+
| <a name="input_scc_workload_protection_trusted_profile_name"></a> [scc\_workload\_protection\_trusted\_profile\_name](#input\_scc\_workload\_protection\_trusted\_profile\_name) | The name to give the trusted profile that is created by this module if `cspm_enabled` is `true. Must begin with a letter.` | `string` | `"workload-protection-trusted-profile"` | no |
119140
| <a name="input_scc_wp_service_plan"></a> [scc\_wp\_service\_plan](#input\_scc\_wp\_service\_plan) | IBM service pricing plan. | `string` | `"free-trial"` | no |
120141

121142
### Outputs
122143

123144
| Name | Description |
124145
|------|-------------|
125146
| <a name="output_access_key"></a> [access\_key](#output\_access\_key) | Workload Protection instance access key. |
147+
| <a name="output_account_id"></a> [account\_id](#output\_account\_id) | Account ID of created SCC WP instance. |
126148
| <a name="output_api_endpoint"></a> [api\_endpoint](#output\_api\_endpoint) | API endpoint. |
127149
| <a name="output_crn"></a> [crn](#output\_crn) | CRN of created SCC WP instance. |
128150
| <a name="output_guid"></a> [guid](#output\_guid) | GUID of created SCC WP instance. |

examples/advanced/main.tf

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,38 @@ module "cbr_zone" {
5353
}]
5454
}
5555

56+
########################################################################################################################
57+
# App Config
58+
########################################################################################################################
59+
60+
# Create new App Config instance
61+
module "app_config" {
62+
source = "terraform-ibm-modules/app-configuration/ibm"
63+
version = "1.5.1"
64+
region = var.region
65+
resource_group_id = module.resource_group.resource_group_id
66+
app_config_plan = "basic"
67+
app_config_name = "${var.prefix}-app-config"
68+
app_config_tags = var.resource_tags
69+
enable_config_aggregator = true
70+
config_aggregator_trusted_profile_name = "${var.prefix}-app-config-tp"
71+
}
72+
5673
########################################################################################################################
5774
# SCC WP instance
5875
########################################################################################################################
5976

6077
module "scc_wp" {
61-
source = "../.."
62-
name = var.prefix
63-
region = var.region
64-
resource_group_id = module.resource_group.resource_group_id
65-
resource_tags = var.resource_tags
66-
access_tags = var.access_tags
67-
cloud_monitoring_instance_crn = module.cloud_monitoring.crn
78+
source = "../.."
79+
name = var.prefix
80+
region = var.region
81+
resource_group_id = module.resource_group.resource_group_id
82+
resource_tags = var.resource_tags
83+
access_tags = var.access_tags
84+
cloud_monitoring_instance_crn = module.cloud_monitoring.crn
85+
cspm_enabled = true
86+
app_config_crn = module.app_config.app_config_crn
87+
scc_workload_protection_trusted_profile_name = "${var.prefix}-wp-tp"
6888

6989
cbr_rules = [
7090
{

examples/advanced/provider.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,14 @@ provider "ibm" {
66
ibmcloud_api_key = var.ibmcloud_api_key
77
region = var.region
88
}
9+
10+
data "ibm_iam_auth_token" "auth_token" {}
11+
12+
# Null resource replaced with restapi_object to enable CSPM
13+
provider "restapi" {
14+
uri = "https://resource-controller.cloud.ibm.com"
15+
headers = {
16+
Authorization = data.ibm_iam_auth_token.auth_token.iam_access_token
17+
}
18+
write_returns_object = true
19+
}

examples/advanced/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.70.0, <2.0.0"
88
}
9+
restapi = {
10+
source = "Mastercard/restapi"
11+
version = ">=1.20.0, <2.0.0"
12+
}
913
}
1014
}

examples/basic/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ module "scc_wp" {
2121
resource_group_id = module.resource_group.resource_group_id
2222
resource_tags = var.resource_tags
2323
access_tags = var.access_tags
24+
cspm_enabled = false
2425
}

examples/basic/provider.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,14 @@ provider "ibm" {
66
ibmcloud_api_key = var.ibmcloud_api_key
77
region = var.region
88
}
9+
10+
data "ibm_iam_auth_token" "auth_token" {}
11+
12+
# Null resource replaced with restapi_object to enable CSPM
13+
provider "restapi" {
14+
uri = "https://resource-controller.cloud.ibm.com"
15+
headers = {
16+
Authorization = data.ibm_iam_auth_token.auth_token.iam_access_token
17+
}
18+
write_returns_object = true
19+
}

examples/basic/version.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.70.0"
7+
version = "1.76.1"
8+
}
9+
restapi = {
10+
source = "Mastercard/restapi"
11+
version = "1.20.0"
812
}
913
}
1014
}

examples/enterprise/README.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,52 @@
22

33
> Only supported in an enterprise account.
44
5-
This example demonstrates the full deployment of:
5+
This example demonstrates a full deployment using modular Terraform code, including:
66

7-
- IBM Cloud App Configuration
8-
- IBM Cloud Security and Compliance Center Workload Protection (SCC-WP)
9-
- IAM Trusted Profile Template with 3 Trusted Profiles
10-
- Template assignment to account groups
11-
- Configuration Aggregator to link SCC-WP with App Config
7+
- **IBM Cloud App Configuration** (App Config)
8+
- **IBM Cloud Security and Compliance Center Workload Protection** (SCC-WP)
9+
- **IAM Trusted Profiles** for secure integration
10+
- **Resource Group** creation or reuse
11+
- **Configuration Aggregator** to link SCC-WP with App Config
1212

1313
---
1414

15-
## Flow Overview
15+
## Module Overview
16+
17+
- **Resource Group Module**
18+
Creates or reuses a resource group for all resources.
19+
20+
- **SCC Workload Protection Module**
21+
Deploys the SCC-WP instance, attaches tags, and (optionally) enables CSPM and trusted profiles based on input variables.
22+
23+
- **App Config Module**
24+
Deploys an App Config instance with enterprise plan, tags, and enables the configuration aggregator with a trusted profile.
1625

17-
1. **Create or reuse a resource group**
18-
A resource group is created or reused.
26+
---
27+
28+
## Flow Overview
1929

20-
2. **Deploy App Config**
21-
App Config is deployed along with a collection for organizing features and properties.
30+
1. **Resource Group**
31+
A resource group is created or reused for all resources.
2232

23-
3. **Deploy SCC Workload Protection**
24-
SCC-WP is deployed with the `graduated-tier` plan.
33+
2. **App Config**
34+
Deploys App Config with the enterprise plan, tags, and enables the configuration aggregator with a trusted profile.
2535

26-
4. **Create a Trusted Profile Template with 3 profiles**
27-
- **App Config -- Enterprise**
28-
For IAM template management across the enterprise.
29-
- **App Config -- General**
30-
For reading platform and IAM services.
31-
- **SCC-WP Profile**
32-
For integrating SCC-WP with App Config and enterprise usage.
36+
3. **SCC Workload Protection**
37+
Deploys SCC-WP with the `graduated-tier` plan, attaches resource and access tags, and (optionally) enables CSPM and trusted profiles for secure integration.
3338

34-
5. **Assign the template to account groups**
35-
All child accounts or specific account groups receive the profile template.
39+
4. **Trusted Profiles**
40+
Trusted profiles are created and linked as needed for App Config and SCC-WP, with enterprise access policies conditionally included if enabled.
3641

37-
6. **Create SCC-WP Config Aggregator**
38-
The aggregator connects SCC-WP to App Config and uses the enterprise trusted profile and template ID to enforce secure access.
42+
5. **Configuration Aggregator**
43+
Connects SCC-WP to App Config using the trusted profile and template ID for secure access across the enterprise.
3944

4045
---
4146

4247
## Notes
4348

44-
- The `trusted_profile_links` block in each trusted profile is used to **link the profile to a specific CRN**, like a VSI or App Config instance, enabling the identity to assume the trusted profile.
49+
- The `trusted_profile_links` block in each trusted profile links the profile to a specific CRN (e.g., VSI or App Config instance), enabling the identity to assume the trusted profile.
50+
- Enterprise-specific access policies are conditionally added based on input variables (e.g., `enterprise_enabled`).
4551

4652
---
4753

0 commit comments

Comments
 (0)