Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 6 additions & 2 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
]
},
{
"key": "prefix"
"key": "prefix",
"required": true,
"decsription": "Prefix to add to all resources created by this solution. To not use any prefix value, you can enter the string `__NULL__`."
},
{
"key": "use_existing_resource_group"
Expand Down Expand Up @@ -553,7 +555,9 @@
]
},
{
"key": "prefix"
"key": "prefix",
"required": true,
"decsription": "Prefix to add to all resources created by this solution. To not use any prefix value, you can enter the string `__NULL__`."
},
{
"key": "cluster_id"
Expand Down
4 changes: 2 additions & 2 deletions solutions/agents/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ module "observability_agents" {
wait_till = var.wait_till
# Cloud Monitoring (Sysdig) Agent
cloud_monitoring_enabled = var.cloud_monitoring_enabled
cloud_monitoring_agent_name = var.prefix != null ? "${var.prefix}-${var.cloud_monitoring_agent_name}" : var.cloud_monitoring_agent_name
cloud_monitoring_agent_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cloud_monitoring_agent_name}" : var.cloud_monitoring_agent_name
cloud_monitoring_agent_namespace = var.cloud_monitoring_agent_namespace
cloud_monitoring_endpoint_type = var.cloud_monitoring_endpoint_type
cloud_monitoring_access_key = var.cloud_monitoring_access_key
cloud_monitoring_secret_name = var.prefix != null ? "${var.prefix}-${var.cloud_monitoring_secret_name}" : var.cloud_monitoring_secret_name
cloud_monitoring_secret_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cloud_monitoring_secret_name}" : var.cloud_monitoring_secret_name
cloud_monitoring_metrics_filter = var.cloud_monitoring_metrics_filter
cloud_monitoring_container_filter = var.cloud_monitoring_container_filter
cloud_monitoring_agent_tags = var.cloud_monitoring_agent_tags
Expand Down
4 changes: 2 additions & 2 deletions solutions/agents/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ variable "ibmcloud_api_key" {

variable "prefix" {
type = string
description = "The prefix for resources created by this solution."
default = null
description = "The prefix to add to all resources that this solution creates. To not use any prefix value, you can set this value to `null` or an empty string."
default = "dev"
}
variable "provider_visibility" {
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
Expand Down
36 changes: 18 additions & 18 deletions solutions/instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ locals {

default_cos_region = var.cos_region != null ? var.cos_region : var.region

cos_key_ring_name = var.prefix != null ? "${var.prefix}-${var.cos_key_ring_name}" : var.cos_key_ring_name
cos_key_name = var.prefix != null ? "${var.prefix}-${var.cos_key_name}" : var.cos_key_name
log_archive_cos_bucket_name = var.prefix != null ? "${var.prefix}-${var.log_archive_cos_bucket_name}" : var.log_archive_cos_bucket_name
at_cos_target_bucket_name = var.prefix != null ? "${var.prefix}-${var.at_cos_target_bucket_name}" : var.at_cos_target_bucket_name
cos_key_ring_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cos_key_ring_name}" : var.cos_key_ring_name
cos_key_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cos_key_name}" : var.cos_key_name
log_archive_cos_bucket_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.log_archive_cos_bucket_name}" : var.log_archive_cos_bucket_name
at_cos_target_bucket_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.at_cos_target_bucket_name}" : var.at_cos_target_bucket_name

cos_instance_crn = var.existing_cos_instance_crn != null ? var.existing_cos_instance_crn : length(module.cos_instance) != 0 ? module.cos_instance[0].cos_instance_crn : null
cos_instance_guid = var.existing_cos_instance_crn == null ? length(module.cos_instance) != 0 ? module.cos_instance[0].cos_instance_guid : null : element(split(":", var.existing_cos_instance_crn), length(split(":", var.existing_cos_instance_crn)) - 3)
Expand Down Expand Up @@ -49,12 +49,12 @@ locals {
cos_target_bucket_name = var.existing_at_cos_target_bucket_name != null ? var.existing_at_cos_target_bucket_name : var.enable_at_event_routing_to_cos_bucket ? module.cos_bucket[0].buckets[local.at_cos_target_bucket_name].bucket_name : null
cos_resource_group_id = var.cos_resource_group_name != null ? module.cos_resource_group[0].resource_group_id : module.resource_group.resource_group_id
cos_target_bucket_endpoint = var.existing_at_cos_target_bucket_endpoint != null ? var.existing_at_cos_target_bucket_endpoint : var.enable_at_event_routing_to_cos_bucket ? module.cos_bucket[0].buckets[local.at_cos_target_bucket_name].s3_endpoint_private : null
cos_target_name = var.prefix != null ? "${var.prefix}-cos-target" : "cos-target"
cloud_logs_target_name = var.prefix != null ? "${var.prefix}-cloud-logs-target" : "cloud-logs-target"
at_cos_route_name = var.prefix != null ? "${var.prefix}-at-cos-route" : "at-cos-route"
at_cloud_logs_route_name = var.prefix != null ? "${var.prefix}-at-cloud-logs-route" : "at-cloud-logs-route"
metric_router_target_name = var.prefix != null ? "${var.prefix}-cloud-monitoring-target" : "cloud-monitoring-target"
metric_router_route_name = var.prefix != null ? "${var.prefix}-metric-routing-route" : "metric-routing-route"
cos_target_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-cos-target" : "cos-target"
cloud_logs_target_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-cloud-logs-target" : "cloud-logs-target"
at_cos_route_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-at-cos-route" : "at-cos-route"
at_cloud_logs_route_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-at-cloud-logs-route" : "at-cloud-logs-route"
metric_router_target_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-cloud-monitoring-target" : "cloud-monitoring-target"
metric_router_route_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-metric-routing-route" : "metric-routing-route"

default_metrics_router_route = var.enable_metrics_routing_to_cloud_monitoring ? [{
name = local.metric_router_route_name
Expand Down Expand Up @@ -131,13 +131,13 @@ locals {


# Cloud Logs data bucket
cloud_log_data_bucket = var.prefix != null ? "${var.prefix}-${var.cloud_log_data_bucket_name}" : var.cloud_log_data_bucket_name
cloud_log_data_bucket = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cloud_log_data_bucket_name}" : var.cloud_log_data_bucket_name

parsed_log_data_bucket_name = var.existing_cloud_logs_data_bucket_crn != null ? split(":", var.existing_cloud_logs_data_bucket_crn) : []
existing_cloud_log_data_bucket_name = length(local.parsed_log_data_bucket_name) > 0 ? local.parsed_log_data_bucket_name[1] : null

# Cloud Logs metrics bucket
cloud_log_metrics_bucket = var.prefix != null ? "${var.prefix}-${var.cloud_log_metrics_bucket_name}" : var.cloud_log_metrics_bucket_name
cloud_log_metrics_bucket = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cloud_log_metrics_bucket_name}" : var.cloud_log_metrics_bucket_name

parsed_log_metrics_bucket_name = var.existing_cloud_logs_metrics_bucket_crn != null ? split(":", var.existing_cloud_logs_metrics_bucket_crn) : []
existing_cloud_log_metrics_bucket_name = length(local.parsed_log_metrics_bucket_name) > 0 ? local.parsed_log_metrics_bucket_name[1] : null
Expand All @@ -157,7 +157,7 @@ locals {
module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.6"
resource_group_name = var.use_existing_resource_group == false ? (var.prefix != null ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
resource_group_name = var.use_existing_resource_group == false ? ((var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
}

Expand All @@ -168,16 +168,16 @@ module "cos_resource_group" {
}
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.6"
resource_group_name = var.prefix != null ? "${var.prefix}-${var.cos_resource_group_name}" : var.cos_resource_group_name
resource_group_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cos_resource_group_name}" : var.cos_resource_group_name
}

#######################################################################################################################
# Observability Instance
#######################################################################################################################

locals {
cloud_monitoring_instance_name = var.prefix != null ? "${var.prefix}-${var.cloud_monitoring_instance_name}" : var.cloud_monitoring_instance_name
cloud_logs_instance_name = var.prefix != null ? "${var.prefix}-cloud-logs" : var.cloud_logs_instance_name
cloud_monitoring_instance_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cloud_monitoring_instance_name}" : var.cloud_monitoring_instance_name
cloud_logs_instance_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-cloud-logs" : var.cloud_logs_instance_name
cloud_logs_data_bucket_crn = var.existing_cloud_logs_data_bucket_crn != null ? var.existing_cloud_logs_data_bucket_crn : module.cos_bucket[0].buckets[local.cloud_log_data_bucket].bucket_crn
cloud_log_metrics_bucket_crn = var.existing_cloud_logs_metrics_bucket_crn != null ? var.existing_cloud_logs_metrics_bucket_crn : module.cos_bucket[0].buckets[local.cloud_log_metrics_bucket].bucket_crn
cloud_logs_buckets = [local.cloud_logs_data_bucket_crn, local.cloud_log_metrics_bucket_crn]
Expand Down Expand Up @@ -281,7 +281,7 @@ module "observability_instance" {
cloud_logs_existing_en_instances = [for index, _ in local.cloud_logs_existing_en_instances : {
en_instance_id = module.en_crn_parser[index]["service_instance"]
en_region = module.en_crn_parser[index]["region"]
en_integration_name = var.prefix != null ? "${var.prefix}-${local.cloud_logs_existing_en_instances[index]["integration_name"]}" : local.cloud_logs_existing_en_instances[index]["integration_name"]
en_integration_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${local.cloud_logs_existing_en_instances[index]["integration_name"]}" : local.cloud_logs_existing_en_instances[index]["integration_name"]
skip_en_auth_policy = local.cloud_logs_existing_en_instances[index]["skip_en_auth_policy"]
}]
skip_logs_routing_auth_policy = var.skip_logs_routing_auth_policy
Expand Down Expand Up @@ -452,7 +452,7 @@ module "cos_instance" {
version = "8.16.4"
resource_group_id = local.cos_resource_group_id
create_cos_instance = true
cos_instance_name = var.prefix != null ? "${var.prefix}-${var.cos_instance_name}" : var.cos_instance_name
cos_instance_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.cos_instance_name}" : var.cos_instance_name
cos_tags = var.cos_instance_tags
existing_cos_instance_id = var.existing_cos_instance_crn
access_tags = var.cos_instance_access_tags
Expand Down
4 changes: 2 additions & 2 deletions solutions/instances/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ variable "region" {

variable "prefix" {
type = string
description = "The prefix to add to all resources that this solution creates."
default = null
description = "The prefix to add to all resources that this solution creates. To not use any prefix value, you can set this value to `null` or an empty string."
default = "dev"
}
variable "provider_visibility" {
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
Expand Down