Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit 935e3a0

Browse files
authored
feat: Exposed new variable add_bucket_name_suffix in the DA with a default value of true to help ensure a unique bucket name gets created.<br>* Updated DA to use IBM provider version 1.63.0 which has a fix for known [provider bug](IBM-Cloud/terraform-provider-ibm#5131) (#18)
1 parent 2421d93 commit 935e3a0

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

solutions/instances/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@ This solution supports the following:
77
- Provisioning and configuring of a Security and Compliance Center Workload Protection instance.
88

99
**NB:** This solution is not intended to be called by one or more other modules since it contains a provider configurations, meaning it is not compatible with the `for_each`, `count`, and `depends_on` arguments. For more information see [Providers Within Modules](https://developer.hashicorp.com/terraform/language/modules/develop/providers)
10-
11-
## Known limitations
12-
There is currently a known issue with the IBM provider (https://github.com/IBM-Cloud/terraform-provider-ibm/issues/5131) where the provider is always trying to use the `us-south` endpoint when trying to configure the SCC instance, even if the instance is not in `us-south`. You will see the following error on apply:
13-
```
14-
│ Error: UpdateSettingsWithContext failed The requested resource was not found
15-
```
16-
As a workaround, you can set the following environment variable before running apply:
17-
```
18-
export IBMCLOUD_SCC_API_ENDPOINT=https://REGION.compliance.cloud.ibm.com
19-
```
20-
where `REGION` is the value you have set for the modules `region` input variable.
21-
22-
![scc](https://github.com/terraform-ibm-modules/terraform-ibm-scc-da/blob/main/reference-architecture/scc.svg)

solutions/instances/catalogValidationValues.json.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"ibmcloud_api_key": $VALIDATION_APIKEY,
33
"resource_group_name": $PREFIX,
44
"existing_kms_guid": $HPCS_US_SOUTH_GUID,
5-
"kms_region": "us-south",
6-
"scc_cos_bucket_name": $PREFIX
5+
"kms_region": "us-south"
76
}

solutions/instances/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ module "kms" {
2626
}
2727
count = var.existing_scc_cos_kms_key_crn != null || var.existing_scc_cos_bucket_name != null ? 0 : 1 # no need to create any KMS resources if passing an existing key, or bucket
2828
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
29-
version = "4.8.1"
30-
resource_group_id = null # rg only needed if creating KP instance
29+
version = "4.8.3"
3130
create_key_protect_instance = false
3231
region = var.kms_region
3332
existing_kms_instance_guid = var.existing_kms_guid
@@ -79,7 +78,7 @@ module "cos" {
7978
}
8079
count = var.existing_scc_cos_bucket_name == null ? 1 : 0 # no need to call COS module if consumer is passing existing COS bucket
8180
source = "terraform-ibm-modules/cos/ibm//modules/fscloud"
82-
version = "7.4.1"
81+
version = "7.5.0"
8382
resource_group_id = module.resource_group.resource_group_id
8483
create_cos_instance = var.existing_cos_instance_crn == null ? true : false # don't create instance if existing one passed in
8584
create_resource_key = false
@@ -90,6 +89,7 @@ module "cos" {
9089
cos_plan = "standard"
9190
bucket_configs = [{
9291
access_tags = var.scc_cos_bucket_access_tags
92+
add_bucket_name_suffix = var.add_bucket_name_suffix
9393
bucket_name = var.scc_cos_bucket_name
9494
kms_encryption_enabled = true
9595
kms_guid = var.existing_kms_guid
@@ -112,7 +112,7 @@ module "cos" {
112112

113113
module "scc" {
114114
source = "terraform-ibm-modules/scc/ibm"
115-
version = "1.1.2"
115+
version = "1.1.3"
116116
resource_group_id = module.resource_group.resource_group_id
117117
region = var.scc_region
118118
instance_name = var.scc_instance_name

solutions/instances/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ variable "cos_instance_access_tags" {
101101
variable "scc_cos_bucket_name" {
102102
type = string
103103
default = "base-security-services-bucket"
104-
description = "The name to use when creating the SCC Cloud Object Storage bucket (NOTE: bucket names are globally unique)."
104+
description = "The name to use when creating the SCC Cloud Object Storage bucket (NOTE: bucket names are globally unique). If 'add_bucket_name_suffix' is set to true, a random 4 characters will be added to this name to help ensure bucket name is globally unique."
105+
}
106+
107+
variable "add_bucket_name_suffix" {
108+
type = bool
109+
description = "Add random generated suffix (4 characters long) to the newly provisioned SCC COS bucket name. Only used if not passing existing bucket. set to false if you want full control over bucket naming using the 'scc_cos_bucket_name' variable."
110+
default = true
105111
}
106112

107113
variable "scc_cos_bucket_access_tags" {

solutions/instances/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.62.0"
7+
version = "1.63.0"
88
}
99
}
1010
}

tests/pr_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ func TestInstancesInSchematics(t *testing.T) {
5959
WaitJobCompleteMinutes: 60,
6060
})
6161

62-
// Workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/5131
63-
options.AddWorkspaceEnvVar("IBMCLOUD_SCC_API_ENDPOINT", "https://private."+region+".compliance.cloud.ibm.com", false, false)
64-
6562
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
6663
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
6764
{Name: "resource_group_name", Value: options.Prefix, DataType: "string"},
6865
{Name: "existing_kms_guid", Value: permanentResources["hpcs_south"], DataType: "string"},
6966
{Name: "kms_region", Value: "us-south", DataType: "string"}, // KMS instance is in us-south
7067
{Name: "scc_region", Value: region, DataType: "string"},
7168
{Name: "cos_region", Value: region, DataType: "string"},
72-
{Name: "scc_cos_bucket_name", Value: options.Prefix, DataType: "string"},
7369
{Name: "cos_instance_tags", Value: options.Tags, DataType: "list(string)"},
7470
{Name: "scc_instance_tags", Value: options.Tags, DataType: "list(string)"},
7571
{Name: "scc_wp_instance_tags", Value: options.Tags, DataType: "list(string)"},

0 commit comments

Comments
 (0)