-
Notifications
You must be signed in to change notification settings - Fork 0
Changes from all commits
b1f926c
51c5dd5
cabb436
61f95e6
b4a6a39
b7122e1
b4cb06d
ce92eab
329644e
08e4fe9
08be0d6
2bcee7d
4dc70df
7ebec8e
529c2ff
dbcff43
4876849
5c53976
0fc92f0
f382514
1e160ca
6b424a9
ab934e5
de24cf1
e00ada3
1779c15
7fbb1a8
e417d0e
087e84e
54a7360
9e88845
47674b5
f73890a
0f89504
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ terraform { | |
| required_providers { | ||
| ibm = { | ||
| source = "IBM-Cloud/ibm" | ||
| version = ">= 1.66.0" | ||
| version = "1.66.0" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| profile_version = "1.0.0" | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # SCC attachment | ||
| ############################################################################## | ||
|
|
||
| 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", | ||
| ] | ||
| }, | ||
jor2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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" | ||
| } | ||
jor2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ### 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 --> | ||
| 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 | ||
ocofaigh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| 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 | ||
| } | ||
| } | ||
| } | ||
| 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 | ||
| } | ||
| ] | ||
| } |
| 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." | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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." | ||
jor2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| 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." | ||
| } | ||
| 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" | ||
| } | ||
| } | ||
| } |

Uh oh!
There was an error while loading. Please reload this page.