Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b1f926c
feat: add profile submodule
Mar 25, 2024
51c5dd5
fix: example
Mar 26, 2024
cabb436
feature: add profile functionality
Mar 27, 2024
61f95e6
feat: add scc profiles
Apr 2, 2024
b4a6a39
Merge remote-tracking branch 'origin' into profiles
Apr 2, 2024
b7122e1
feat: update example
Apr 2, 2024
b4cb06d
fix: Update version.tf
jor2 Apr 3, 2024
ce92eab
fix: Update version.tf
jor2 Apr 3, 2024
329644e
fix: no provider
Apr 3, 2024
08e4fe9
fix: SKIP UPGRADE TEST
Apr 3, 2024
08be0d6
Merge branch 'main' into profiles
jor2 Apr 8, 2024
2bcee7d
Merge branch 'main' into profiles
jor2 Apr 12, 2024
4dc70df
Merge branch 'main' into profiles
jor2 Apr 14, 2024
7ebec8e
Merge branch 'main' into profiles
jor2 Apr 17, 2024
529c2ff
feat: add profile functionality for individual rules
Apr 18, 2024
dbcff43
feat: add profile functionality for individual rules
Apr 18, 2024
4876849
feat: add profile functionality for individual rules
Apr 18, 2024
5c53976
feat: add profile functionality for individual rules
Apr 18, 2024
0fc92f0
fix: docs
Apr 18, 2024
f382514
fix: address feedback
Apr 18, 2024
1e160ca
fix: address feedback
Apr 18, 2024
6b424a9
fix: address feedback
Apr 18, 2024
ab934e5
fix: address feedback
Apr 18, 2024
de24cf1
fix: address feedback
Apr 18, 2024
e00ada3
fix: address feedback
Apr 18, 2024
1779c15
Merge branch 'main' into profiles
jor2 Apr 21, 2024
7fbb1a8
Merge branch 'main' of github.com:terraform-ibm-modules/terraform-ibm…
May 23, 2024
e417d0e
Merge branch 'main' into profiles
jor2 May 23, 2024
087e84e
Merge branch 'profiles' of github.com:terraform-ibm-modules/terraform…
May 23, 2024
54a7360
fix: update versions
May 23, 2024
9e88845
fix: update versions
May 23, 2024
47674b5
fix: merge conflicts
Jun 4, 2024
f73890a
fix: merge conflicts
Jun 4, 2024
0f89504
fix: merge
Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This module configures an IBM Cloud Security and Compliance instance.
* [terraform-ibm-scc](#terraform-ibm-scc)
* [Submodules](./modules)
* [attachment](./modules/attachment)
* [profile](./modules/profile)
* [Examples](./examples)
* [Basic example](./examples/basic)
* [Complete example with CBR rules](./examples/complete)
Expand Down Expand Up @@ -54,9 +55,6 @@ You need the following permissions to run this module.
- Account Management
- Security and Compliance Center service
- `Administrator` platform access
- IAM Services
- Event Notifications service
- `Manager` service access


<!-- Below content is automatically populated via pre-commit hook -->
Expand All @@ -66,7 +64,7 @@ You need the following permissions to run this module.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.64.1, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.65.1, <2.0.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, <1.0.0 |

### Modules
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.66.0"
version = "1.66.0"
}
}
}
41 changes: 41 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,47 @@ module "create_scc_instance" {
]
}

##############################################################################
# SCC custom profile
##############################################################################

module "create_scc_profile" {
source = "../../modules/profile/."
instance_id = module.create_scc_instance.guid
controls = [
# Apply 3 controls from IBM Cloud Framework for Financial Services control library version 1.6.0
{
control_library_name = "IBM Cloud Framework for Financial Services",
control_library_version = "1.6.0"
control_name_list = [
"AC",
"AC-1",
"AC-1(a)",
]
},
# Apply 4 controls from CIS IBM Cloud Foundations Benchmark control library version 1.0.0
{
control_library_name = "CIS IBM Cloud Foundations Benchmark",
control_library_version = "1.0.0"
control_name_list = [
"1.16",
"1.18",
"1.19",
"1.4",
]
},
# Apply all controls from SOC 2 control library version 1.0.0
{
control_library_name = "SOC 2",
control_library_version = "1.0.0"
add_all_controls = true
},
]
profile_name = "${var.prefix}-profile"
profile_description = "scc-custom"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This use case makes no sense? What I would expect is that the code should be creating a custom profile made up of controls. It shouldn't matter about what control library they came from

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names are weird for each control, just numbers or AC-1(B) etc
Screenshot 2024-04-18 at 01 02 38

profile_version = "1.0.0"
}

##############################################################################
# SCC attachment
##############################################################################
Expand Down
10 changes: 5 additions & 5 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ output "cos_bucket" {
depends_on = [module.create_scc_instance]
}

output "scc_profile_attachment_id" {
description = "SCC profile attachment ID"
value = module.create_profile_attachment.id
output "profile_id" {
description = "The id of the SCC profile created by this module"
value = module.create_scc_profile.profile_id
}

output "scc_profile_attachment_parameters" {
output "scc_profile_attachment_id" {
description = "SCC profile attachment ID"
value = module.create_profile_attachment.attachment_parameters
value = module.create_profile_attachment.id
}

output "wp_crn" {
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.64.1"
version = ">= 1.65.1"
}
}
}
2 changes: 1 addition & 1 deletion modules/attachment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module "create_scc_profile_attachment " {
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.64.1, <2.0.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.65.1, <2.0.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/attachment/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">=1.64.1, <2.0.0"
version = ">=1.65.1, <2.0.0"
}
}
}
96 changes: 96 additions & 0 deletions modules/profile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# SCC Profile Module

This module creates an SCC Profile (https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-build-custom-profiles&interface=ui). A profile is a grouping of controls that can be evaluated for compliance.

### Usage

```hcl
provider "ibm" {
ibmcloud_api_key = "XXXXXXXXXX" # pragma: allowlist secret
region = "us-south"
}

# - SCC Profile
module "create_scc_profile" {
source = "terraform-ibm-modules/scc/ibm//modules/profile"
instance_id = "00000000-1111-2222-3333-444444444444"
controls = [
# Apply 3 controls from IBM Cloud Framework for Financial Services control library version 1.6.0
{
control_library_name = "IBM Cloud Framework for Financial Services",
control_library_version = "1.6.0"
control_name_list = [
"AC",
"AC-1",
"AC-1(a)",
]
},
# Apply 4 controls from CIS IBM Cloud Foundations Benchmark control library version 1.0.0
{
control_library_name = "CIS IBM Cloud Foundations Benchmark",
control_library_version = "1.0.0"
control_name_list = [
"1.16",
"1.18",
"1.19",
"1.4",
]
},
# Apply all controls from SOC 2 control library version 1.0.0
{
control_library_name = "SOC 2",
control_library_version = "1.0.0"
add_all_controls = true
},
]
profile_name = "scc-profile"
profile_description = "scc-custom"
profile_version = "1.0.0"
}
```

### Required IAM access policies
You need the following permissions to run this module.

- Account Management
- Security and Compliance Center service
- `Editor` platform access

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.65.1, <2.0.0 |

### Modules

No modules.

### Resources

| Name | Type |
|------|------|
| [ibm_scc_profile.scc_profile_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/scc_profile) | resource |
| [ibm_scc_control_libraries.scc_control_libraries](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/scc_control_libraries) | data source |
| [ibm_scc_control_library.scc_control_library](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/scc_control_library) | data source |

### Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_controls"></a> [controls](#input\_controls) | The list of control\_library\_ids that are used to create the profile. Constraints: The maximum length is `600` items. The minimum length is `0` items. | <pre>list(object({<br> control_library_name = string<br> control_library_version = string<br> control_name_list = optional(list(string), ["all_rules"])<br> add_all_controls = optional(bool, false)<br> }))</pre> | `[]` | no |
| <a name="input_default_parameters"></a> [default\_parameters](#input\_default\_parameters) | Each assessment must be assigned a value to evaluate your resources. To customize parameters for your profile, set a new default value. This is optional and if no values are passed then the default values will be used. | <pre>list(object({<br> assessment_type = optional(string)<br> assessment_id = optional(string)<br> parameter_name = optional(string)<br> parameter_default_value = optional(string)<br> parameter_display_name = optional(string)<br> parameter_type = optional(string)<br> }))</pre> | `[]` | no |
| <a name="input_instance_id"></a> [instance\_id](#input\_instance\_id) | The ID of the SCC instance in a particular region. | `string` | n/a | yes |
| <a name="input_profile_description"></a> [profile\_description](#input\_profile\_description) | The description of the profile to be created. | `string` | n/a | yes |
| <a name="input_profile_name"></a> [profile\_name](#input\_profile\_name) | The name of the profile to be created. | `string` | n/a | yes |
| <a name="input_profile_version"></a> [profile\_version](#input\_profile\_version) | The version status of the profile. | `string` | n/a | yes |

### Outputs

| Name | Description |
|------|-------------|
| <a name="output_profile_id"></a> [profile\_id](#output\_profile\_id) | The id of the SCC profile created by this module |
| <a name="output_scc_control_libraries"></a> [scc\_control\_libraries](#output\_scc\_control\_libraries) | The scc control libraries applied to the profile in this module |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
69 changes: 69 additions & 0 deletions modules/profile/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
data "ibm_scc_control_libraries" "scc_control_libraries" {
instance_id = var.instance_id
}

locals {
# Get control libraries id from their name and version specified in var.controls.control_library_name
control_libraries = flatten([for control_library in data.ibm_scc_control_libraries.scc_control_libraries.control_libraries : [
for ctrl in var.controls :
control_library if ctrl.control_library_name == control_library.control_library_name && ctrl.control_library_version == control_library.control_library_version
]
])
}

data "ibm_scc_control_library" "scc_control_library" {
count = length(var.controls)
instance_id = var.instance_id
control_library_id = local.control_libraries[count.index].id
}

locals {
# Map out all controls from relevant control libraries
all_controls_map = flatten([
for index, control_library in local.control_libraries : [
for control in data.ibm_scc_control_library.scc_control_library[index].controls : {
control_library_id = control_library.id
control_library_name = control_library.control_library_name
control_id = control.control_id
control_name = control.control_name
}
]
])

# Get chosen controls from var.controls.control_name_list in local.all_controls_map
relevant_controls_map = flatten([
for ctrl_map in local.all_controls_map : [
for control in var.controls : [
for ctrl in control.control_name_list :
ctrl_map if(ctrl_map.control_name == ctrl && ctrl_map.control_library_name == control.control_library_name) || control.add_all_controls
]
]
])
}

resource "ibm_scc_profile" "scc_profile_instance" {
instance_id = var.instance_id
profile_description = var.profile_description
profile_name = var.profile_name
profile_type = "custom"
profile_version = var.profile_version

dynamic "controls" {
for_each = local.relevant_controls_map
content {
control_library_id = controls.value.control_library_id
control_id = controls.value.control_id
}
}
dynamic "default_parameters" {
for_each = var.default_parameters != null ? var.default_parameters : []
content {
assessment_type = default_parameters.value.assessment_type
assessment_id = default_parameters.value.assessment_id
parameter_name = default_parameters.value.parameter_name
parameter_default_value = default_parameters.value.parameter_default_value
parameter_display_name = default_parameters.value.parameter_display_name
parameter_type = default_parameters.value.parameter_type
}
}
}
20 changes: 20 additions & 0 deletions modules/profile/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
########################################################################################################################
# Outputs
########################################################################################################################

output "profile_id" {
description = "The id of the SCC profile created by this module"
value = ibm_scc_profile.scc_profile_instance.profile_id
}

output "scc_control_libraries" {
description = "The scc control libraries applied to the profile in this module"
value = [
for control_lib in local.control_libraries : {
name = control_lib.control_library_name
id = control_lib.id
version = control_lib.control_library_version
controls_count = control_lib.controls_count
}
]
}
47 changes: 47 additions & 0 deletions modules/profile/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
########################################################################################################################
# Input variables
########################################################################################################################

variable "instance_id" {
type = string
description = "The ID of the SCC instance in a particular region."
}

variable "profile_name" {
type = string
description = "The name of the profile to be created."
}

variable "profile_description" {
type = string
description = "The description of the profile to be created."
}

variable "profile_version" {
type = string
description = "The version status of the profile."
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm I would expect there to be a variable to specify the profile version, but I don't see that as an option with the provider: https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/scc_profile

Might be a bug, I have reached out to SCC team

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it, but it didn't seem to take affect. still says version is 0.0.0. Maybe custom can't have versions?

variable "controls" {
type = list(object({
control_library_name = string
control_library_version = string
control_name_list = optional(list(string), ["all_rules"])
add_all_controls = optional(bool, false)
}))
default = []
description = "The list of control_library_ids that are used to create the profile. Constraints: The maximum length is `600` items. The minimum length is `0` items."
}

variable "default_parameters" {
type = list(object({
assessment_type = optional(string)
assessment_id = optional(string)
parameter_name = optional(string)
parameter_default_value = optional(string)
parameter_display_name = optional(string)
parameter_type = optional(string)
}))
default = []
description = "Each assessment must be assigned a value to evaluate your resources. To customize parameters for your profile, set a new default value. This is optional and if no values are passed then the default values will be used."
}
10 changes: 10 additions & 0 deletions modules/profile/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.3.0, <1.7.0"

required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.65.1, <2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">=1.64.1, <2.0.0"
version = ">=1.65.1, <2.0.0"
}

time = {
Expand Down