Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add prefix to en topics and email subscription #166

Merged
merged 12 commits into from
Sep 4, 2024
6 changes: 4 additions & 2 deletions solutions/instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ module "scc_wp" {
locals {
parsed_existing_en_instance_crn = var.existing_en_crn != null ? split(":", var.existing_en_crn) : []
existing_en_guid = length(local.parsed_existing_en_instance_crn) > 0 ? local.parsed_existing_en_instance_crn[7] : null
en_topic = var.prefix != null ? "${var.prefix} - SCC Topic" : "SCC Topic"
en_subscription_email = var.prefix != null ? "${var.prefix} - Email for Security and Compliance Center Subscription" : "Email for Security and Compliance Center Subscription"
}

data "ibm_en_destinations" "en_destinations" {
Expand All @@ -267,7 +269,7 @@ data "ibm_en_destinations" "en_destinations" {
resource "ibm_en_topic" "en_topic" {
count = var.existing_en_crn != null ? 1 : 0
instance_guid = local.existing_en_guid
name = "SCC Topic"
name = local.en_topic
description = "Topic for SCC events routing"
sources {
id = local.scc_instance_crn
Expand All @@ -281,7 +283,7 @@ resource "ibm_en_topic" "en_topic" {
resource "ibm_en_subscription_email" "email_subscription" {
count = var.existing_en_crn != null && length(var.scc_en_email_list) > 0 ? 1 : 0
instance_guid = local.existing_en_guid
name = "Email for Security and Compliance Center Subscription"
name = local.en_subscription_email
description = "Subscription for Security and Compliance Center Events"
destination_id = [for s in toset(data.ibm_en_destinations.en_destinations[count.index].destinations) : s.id if s.type == "smtp_ibm"][0]
topic_id = ibm_en_topic.en_topic[count.index].topic_id
Expand Down
3 changes: 3 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func TestRunUpgradeInstances(t *testing.T) {
})

options.TerraformVars = map[string]interface{}{
"prefix": options.Prefix,
"resource_group_name": options.Prefix,
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
"kms_endpoint_type": "public",
Expand Down Expand Up @@ -242,6 +243,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
ImplicitRequired: false,
Region: region,
TerraformVars: map[string]interface{}{
"prefix": prefix,
"cos_region": region,
"scc_region": region,
"resource_group_name": terraform.Output(t, existingTerraformOptions, "resource_group_name"),
Expand All @@ -268,6 +270,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
// Do not hard fail the test if the implicit destroy steps fail to allow a full destroy of resource to occur
ImplicitRequired: false,
TerraformVars: map[string]interface{}{
"prefix": prefix,
"cos_region": region,
"scc_region": region,
"resource_group_name": terraform.Output(t, existingTerraformOptions, "resource_group_name"),
Expand Down