Skip to content

Commit 8c5caca

Browse files
iamar7Md Anam RaihanSirSpidey
authored
feat: add prefix to atracker resource name (#131)<br>The AT event routing target and routes names were updated to add a prefix(if provided) for consistency with other resource. Also, the new targets and routes with prefix are created before the destroy of old ones which ensures the consumers does not lose event data. Additionally, updated the variable descriptions.
* fix: atracker resource name and variable descriptions * SKIP Upgrade Test --------- Co-authored-by: Md Anam Raihan <[email protected]> Co-authored-by: Allen Dean <[email protected]>
1 parent 07d4a0a commit 8c5caca

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

solutions/instances/main.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ locals {
2626

2727
cos_target_bucket_name = var.existing_at_cos_target_bucket_name != null ? var.existing_at_cos_target_bucket_name : module.cos_bucket[0].buckets[local.at_cos_target_bucket_name].bucket_name
2828
cos_target_bucket_endpoint = var.existing_at_cos_target_bucket_endpoint != null ? var.existing_at_cos_target_bucket_endpoint : module.cos_bucket[0].buckets[local.at_cos_target_bucket_name].s3_endpoint_private
29+
cos_target_name = var.prefix != null ? "${var.prefix}-cos-target" : "cos-target"
30+
log_analysis_target_name = var.prefix != null ? "${var.prefix}-log-analysis-target" : "log-analysis-target"
31+
at_cos_route_name = var.prefix != null ? "${var.prefix}-at-cos-route" : "at-cos-route"
32+
at_log_analysis_route_name = var.prefix != null ? "${var.prefix}-at-log-analysis-route" : "at-log-analysis-route"
2933

3034
bucket_config_1 = var.existing_log_archive_cos_bucket_name == null && var.log_analysis_provision == true ? {
3135
class = var.log_archive_cos_bucket_class
@@ -64,15 +68,15 @@ locals {
6468

6569
kms_region = (length(coalesce(local.bucket_config_map, [])) != 0) ? (var.existing_cos_kms_key_crn == null ? element(split(":", var.existing_kms_instance_crn), length(split(":", var.existing_kms_instance_crn)) - 5) : null) : null
6670
at_cos_route = var.enable_at_event_routing_to_cos_bucket ? [{
67-
route_name = "at-cos-route"
71+
route_name = local.at_cos_route_name
6872
locations = ["*", "global"]
69-
target_ids = [module.observability_instance.activity_tracker_targets["cos-target"].id]
73+
target_ids = [module.observability_instance.activity_tracker_targets[local.cos_target_name].id]
7074
}] : []
7175

7276
at_log_analysis_route = var.enable_at_event_routing_to_log_analysis ? [{
73-
route_name = "at-log-analysis-route"
77+
route_name = local.at_log_analysis_route_name
7478
locations = ["*", "global"]
75-
target_ids = [module.observability_instance.activity_tracker_targets["log-analysis-target"].id]
79+
target_ids = [module.observability_instance.activity_tracker_targets[local.log_analysis_target_name].id]
7680
}] : []
7781

7882
at_routes = concat(local.at_cos_route, local.at_log_analysis_route)
@@ -134,7 +138,7 @@ module "observability_instance" {
134138
endpoint = local.cos_target_bucket_endpoint
135139
instance_id = local.cos_instance_crn
136140
target_region = local.default_cos_region
137-
target_name = "cos-target"
141+
target_name = local.cos_target_name
138142
skip_atracker_cos_iam_auth_policy = false
139143
service_to_service_enabled = true
140144
}
@@ -145,7 +149,7 @@ module "observability_instance" {
145149
instance_id = module.observability_instance.log_analysis_crn
146150
ingestion_key = module.observability_instance.log_analysis_ingestion_key
147151
target_region = var.region
148-
target_name = "log-analysis-target"
152+
target_name = local.log_analysis_target_name
149153
}
150154
] : []
151155

solutions/instances/variables.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variable "use_existing_resource_group" {
2323

2424
variable "resource_group_name" {
2525
type = string
26-
description = "The name of a new or existing resource group to provision resources to. If a prefix input variable is passed, it is prefixed to the value in the `<prefix>-value` format."
26+
description = "The name of a new or existing resource group to provision resources in."
2727
}
2828

2929
variable "region" {
@@ -39,7 +39,7 @@ variable "region" {
3939

4040
variable "prefix" {
4141
type = string
42-
description = "Optional. The prefix to append to all resources that this solution creates."
42+
description = "The prefix to add to all resources that this solution creates."
4343
default = null
4444
}
4545

@@ -55,13 +55,13 @@ variable "log_analysis_provision" {
5555

5656
variable "log_analysis_instance_name" {
5757
type = string
58-
description = "The name of the IBM Cloud Logging instance to create. If a prefix input variable is passed, it is prefixed to the value in the `<prefix>-value` format."
58+
description = "The name of the IBM Cloud Log Analysis instance to create. If a prefix input variable is specified, it's added to the value in the <prefix>-value format."
5959
default = "log-analysis"
6060
}
6161

6262
variable "log_analysis_plan" {
6363
type = string
64-
description = "The IBM Cloud Logging plan to provision. Available values are `7-day`, `14-day`, `30-day`, and `hipaa-30-day`."
64+
description = "The Log Analysis plan to provision. Possible values: `7-day`, `14-day`, `30-day`, and `hipaa-30-day`."
6565
default = "7-day"
6666

6767
validation {
@@ -71,7 +71,7 @@ variable "log_analysis_plan" {
7171
}
7272

7373
variable "log_analysis_service_endpoints" {
74-
description = "The type of the service endpoint that will be set for the IBM Log Analysis instance."
74+
description = "The type of endpoint for the Log Analysis instance. Possible values: `public`, `private`, `public-and-private`."
7575
type = string
7676
default = "private"
7777
validation {
@@ -88,26 +88,26 @@ variable "log_analysis_tags" {
8888

8989
variable "log_analysis_enable_archive" {
9090
type = bool
91-
description = "Enable archive on log analysis instances"
91+
description = "Whether to enable archiving on Log Analysis instances."
9292
default = true
9393
}
9494

9595
variable "activity_tracker_enable_archive" {
9696
type = bool
97-
description = "Enable archive on activity tracker instances"
97+
description = "Whether to enable archiving on Activity Tracker."
9898
default = true
9999
}
100100

101101
variable "log_archive_api_key" {
102102
type = string
103-
description = "Optional. The API key to use to configure log analysis archiving with Cloud Object Storage. If no value is passed, the API key value that was passed in the `ibmcloud_api_key` variable is used."
103+
description = "The API key to use to configure archiving from Log Analysis to Object Storage. If not specified, the API key value in ibmcloud_api_key is used."
104104
sensitive = true
105105
default = null
106106
}
107107

108108
variable "enable_platform_logs" {
109109
type = bool
110-
description = "When set to `true`, the IBM Cloud Logging instance collects the platform log files."
110+
description = "Whether Log Analysis collects platform log files."
111111
default = true
112112
}
113113
##############################################################################
@@ -116,13 +116,13 @@ variable "enable_platform_logs" {
116116

117117
variable "enable_at_event_routing_to_cos_bucket" {
118118
type = bool
119-
description = "Set to true to enable activity tracker event routing to the Cloud Object Storage (COS) bucket."
119+
description = "Whether to enable event routing from Activity Tracker to the Object Storage bucket."
120120
default = true
121121
}
122122

123123
variable "enable_at_event_routing_to_log_analysis" {
124124
type = bool
125-
description = "Set to true to enable activity tracker event routing to the provisioned IBM Cloud Logging instance."
125+
description = "Whether to enable event from Activity Tracker to Log Analysis."
126126
default = false
127127
}
128128

tests/pr_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func TestRunUpgradeSolutionInstances(t *testing.T) {
108108
})
109109

110110
options.TerraformVars = map[string]interface{}{
111+
"prefix": options.Prefix,
111112
"resource_group_name": options.Prefix,
112113
"cos_instance_access_tags": permanentResources["accessTags"],
113114
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],

0 commit comments

Comments
 (0)