Skip to content

Commit 1b8cf96

Browse files
authored
fix: fixed bug where prefix was not being used in instance name in the DA (#76)
1 parent df90dc1 commit 1b8cf96

File tree

4 files changed

+47
-89
lines changed

4 files changed

+47
-89
lines changed

ibm_catalog.json

Lines changed: 25 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"log"
2424
],
2525
"short_description": "Creates and configures an instance of IBM Cloud Logs",
26-
"long_description": "This architecture supports creating and configuring [IBM Cloud Logs](https://www.ibm.com/products/cloud-logs) resources. IBM Cloud Logs is a scalable logging service that persists logs and provides users with capabilities for querying, tailing, and visualizing logs. \n Logs are comprised of events that are typically human-readable and have different formats, for example, unstructured text, JSON, delimiter-separated values, key-value pairs, and so on. The IBM Cloud Logs service can manage general purpose application logs, platform logs, or structured audit events. IBM Cloud Logs can be used with logs from both IBM Cloud services and customer applications.",
26+
"long_description": "This architecture supports creating and configuring [IBM Cloud Logs](https://www.ibm.com/products/cloud-logs) resources. IBM Cloud Logs is a scalable logging service that persists logs and provides users with capabilities for querying, tailing, and visualizing logs. \n Logs are comprised of events that are typically human-readable and have different formats, for example, unstructured text, JSON, delimiter-separated values, key-value pairs, and so on. The IBM Cloud Logs service can manage general purpose application logs, platform logs, or structured audit events. IBM Cloud Logs can be used with logs from both IBM Cloud services and customer applications.\n\nℹ️ This Terraform-based automation is part of a broader suite of IBM-maintained Infrastructure as Code (IaC) assets, each following the naming pattern \"Cloud automation for servicename\" and focusing on single IBM Cloud service. These single-service deployable architectures can be used on their own to streamline and automate service deployments through an [IaC approach](https://cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-understanding-projects), or assembled together into a broader [automated IaC stack](https://cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-config-stack) to automate the deployment of an end-to-end solution architecture.",
2727
"offering_docs_url": "https://github.com/terraform-ibm-modules/terraform-ibm-cloud-logs/blob/main/README.md",
2828
"offering_icon_url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-cloud-logs/refs/heads/main/images/cloud-logs-icon.svg",
2929
"provider_name": "IBM",
3030
"features": [
3131
{
3232
"title": "Cloud Logs",
33-
"description": "Get started with provisioning an instance of IBM Cloud Logs. Explore more about IBM Cloud Logs [here](https://www.ibm.com/products/cloud-logs)."
33+
"description": "Get started with provisioning an instance of IBM Cloud Logs. Explore more about IBM Cloud Logs [here](https://cloud.ibm.com/docs/cloud-logs?topic=cloud-logs-getting-started)."
3434
},
3535
{
3636
"title": "Object Storage buckets for Cloud Logs",
@@ -49,7 +49,7 @@
4949
"description": "Creates and configures policies for the Cloud Logs instance."
5050
}
5151
],
52-
"support_details": "This product is in the community registry, as such support is handled through the originated repo. If you experience issues please open an issue in that repository [https://github.com/terraform-ibm-modules/terraform-ibm-cloud-logs/issues](https://github.com/terraform-ibm-modules/terraform-ibm-cloud-logs/issues). Please note this product is not supported via the IBM Cloud Support Center.",
52+
"support_details": "This product is in the community registry, as such support is handled through the originated repo. If you experience issues please open an issue in that repository [here](https://github.com/terraform-ibm-modules/terraform-ibm-cloud-logs/issues). Please note this product is not supported via the IBM Cloud Support Center.",
5353
"flavors": [
5454
{
5555
"label": "Fully configurable",
@@ -345,26 +345,26 @@
345345
]
346346
},
347347
{
348-
"role_crns": [
349-
"crn:v1:bluemix:public:iam::::role:Administrator"
350-
],
351-
"service_name": "iam-identity",
352-
"notes": "[Optional] Required if creating COS buckets in a separate account from the account Cloud Logs is created in."
348+
"role_crns": ["crn:v1:bluemix:public:iam::::role:Viewer"],
349+
"service_name": "Resource group only",
350+
"notes": "Viewer access is required in the resource group you want to provision in."
351+
},
352+
{
353+
"role_crns": ["crn:v1:bluemix:public:iam::::role:Administrator"],
354+
"service_name": "All Account Management services",
355+
"notes": "[Optional] Required for consuming Account Configuration deployable architecture which creates resource group."
356+
},
357+
{
358+
"role_crns": ["crn:v1:bluemix:public:iam::::role:Administrator"],
359+
"service_name": "All Identity and Access enabled services",
360+
"notes": "[Optional] Required for consuming Account Configuration deployable architecture which creates resource group with account setting."
353361
}
354362
],
355363
"architecture": {
356364
"features": [
357365
{
358-
"title": "cloud logs instance",
359-
"description": "Creates and configures an instance of cloud logs."
360-
},
361-
{
362-
"title": "KMS Keys and Key Rings",
363-
"description": "Supports the creation of Keys and Key Rings for encrypting object storage bucket."
364-
},
365-
{
366-
"title": "Object Storage buckets",
367-
"description": "Creates buckets required for the Cloud Logs instance."
366+
"title": " ",
367+
"description": "Configured to use IBM secure by default standards, but can be edited to fit your use case."
368368
}
369369
],
370370
"diagrams": [
@@ -374,7 +374,7 @@
374374
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-cloud-logs/refs/heads/main/reference-architecture/deployable-architecture-cloud-logs.svg",
375375
"type": "image/svg+xml"
376376
},
377-
"description": "This solution deploys an IBM Cloud Logs instance on IBM Cloud.<br><br> It creates an IBM Cloud Object Storage instance and provisions a storage bucket required to store logs and metrics data. Alternatively, you can provide details of an existing IBM Cloud Object Storage instance. <br><br> In addition, it enables encryption for the object storage bucket by provisioning an IBM Key Protect service instance, where a Key Ring and associated Key are created to manage encryption through IBM Cloud Key Management Services (KMS). You can also choose to provide an existing KMS instance.<br><br>"
377+
"description": "This architecture supports the creation and configuration of an IBM Cloud Logs instance.<br><br> A Cloud Object Storage (COS) instance is required for this topology. Within this instance, two Object Storage buckets will be created to store logs and metrics data. The [Cloud automation for Object Storage](https://cloud.ibm.com/catalog/7a4d68b4-cf8b-40cd-a3d1-f49aff526eb3/architecture/deploy-arch-ibm-cos-68921490-2778-4930-ac6d-bae7be6cd958-global) architecture supports the provisioning of a Cloud Object Storage instance. Alternatively, you can provide the details of an existing Cloud Object Storage instance.<br><br> Additionally, the Object Storage buckets can be encrypted using IBM Cloud Key Management Services (KMS) to enhance security. The [Cloud automation for Key Protect](https://cloud.ibm.com/catalog/7a4d68b4-cf8b-40cd-a3d1-f49aff526eb3/architecture/deploy-arch-ibm-kms-2cad4789-fa90-4886-9c9e-857081c273ee-global) architecture supports the provisioning of a KMS instance where a Key Ring and associated Key will be created by this solution to manage encryption. Alternatively, you may choose to provide the details of an existing KMS instance."
378378
}
379379
]
380380
},
@@ -717,12 +717,6 @@
717717
"crn:v1:bluemix:public:iam::::role:Editor"
718718
]
719719
},
720-
{
721-
"service_name": "resource-group",
722-
"role_crns": [
723-
"crn:v1:bluemix:public:iam::::role:Viewer"
724-
]
725-
},
726720
{
727721
"service_name": "event-notifications",
728722
"role_crns": [
@@ -731,62 +725,16 @@
731725
]
732726
},
733727
{
734-
"role_crns": [
735-
"crn:v1:bluemix:public:iam::::role:Administrator"
736-
],
737-
"service_name": "iam-identity",
738-
"notes": "[Optional] Required if creating COS buckets in a separate account from the account Cloud Logs is created in."
728+
"role_crns": ["crn:v1:bluemix:public:iam::::role:Viewer"],
729+
"service_name": "Resource group only",
730+
"notes": "Viewer access is required in the resource group you want to provision in."
739731
}
740732
],
741733
"architecture": {
742734
"features": [
743735
{
744-
"title": "Cloud Logs instance creation",
745-
"description": "Yes"
746-
},
747-
{
748-
"title": "Use existing Cloud Logs instance",
749-
"description": "No"
750-
},
751-
{
752-
"title": "New resource group creation",
753-
"description": "No"
754-
},
755-
{
756-
"title": "Use existing resource group",
757-
"description": "Yes"
758-
},
759-
{
760-
"title": "COS instance creation",
761-
"description": "No"
762-
},
763-
{
764-
"title": "COS bucket creation",
765-
"description": "Yes"
766-
},
767-
{
768-
"title": "Enforced KMS encryption",
769-
"description": "Yes"
770-
},
771-
{
772-
"title": "KMS instance creation",
773-
"description": "No"
774-
},
775-
{
776-
"title": "KMS key ring and key creation",
777-
"description": "Yes"
778-
},
779-
{
780-
"title": "Use existing KMS key",
781-
"description": "Yes"
782-
},
783-
{
784-
"title": "IAM s2s auth policies creation",
785-
"description": "Yes"
786-
},
787-
{
788-
"title": "Event Notifications integration",
789-
"description": "Yes"
736+
"title": " ",
737+
"description": "Configured to use IBM secure by default standards that can't be changed."
790738
}
791739
],
792740
"diagrams": [
@@ -796,7 +744,7 @@
796744
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-cloud-logs/refs/heads/main/reference-architecture/deployable-architecture-cloud-logs.svg",
797745
"type": "image/svg+xml"
798746
},
799-
"description": "This architecture supports creating and configuring IBM Cloud Logs resources"
747+
"description": "This architecture supports the creation and configuration of an IBM Cloud Logs instance.<br><br> An existing Cloud Object Storage (COS) instance is required for this topology. Within this instance, two Object Storage buckets will be created to store logs and metrics data. <br><br> By default, both Object Storage buckets will be encrypted to enhance security."
800748
}
801749
]
802750
},

reference-architecture/deployable-architecture-cloud-logs.svg

Lines changed: 1 addition & 1 deletion
Loading

solutions/fully-configurable/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ module "resource_group" {
1313
#######################################################################################################################
1414

1515
locals {
16-
prefix = var.prefix != null ? trimspace(var.prefix) != "" ? "${var.prefix}-" : "" : ""
17-
create_cloud_logs = var.existing_cloud_logs_crn == null
18-
cloud_logs_crn = local.create_cloud_logs ? module.cloud_logs[0].crn : var.existing_cloud_logs_crn
16+
prefix = var.prefix != null ? trimspace(var.prefix) != "" ? "${var.prefix}-" : "" : ""
17+
cloud_logs_instance_name = "${local.prefix}${var.cloud_logs_instance_name}"
18+
create_cloud_logs = var.existing_cloud_logs_crn == null
19+
cloud_logs_crn = local.create_cloud_logs ? module.cloud_logs[0].crn : var.existing_cloud_logs_crn
1920
# Even though we're only performing a comparison (var.ibmcloud_cos_api_key != null),
2021
# Terraform treats the entire value as "tainted" due to sensitivity.
2122
# Later, in the cloud_logs module, where the data_storage input variable is used in a for_each loop,
@@ -30,7 +31,7 @@ module "cloud_logs" {
3031
source = "../.."
3132
resource_group_id = module.resource_group.resource_group_id
3233
region = var.region
33-
instance_name = var.cloud_logs_instance_name
34+
instance_name = local.cloud_logs_instance_name
3435
plan = "standard" # not a variable because there is only one option
3536
resource_tags = var.cloud_logs_resource_tags
3637
access_tags = var.cloud_logs_access_tags

solutions/fully-configurable/variables.tf

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,33 @@ variable "existing_resource_group_name" {
1717
variable "prefix" {
1818
type = string
1919
nullable = true
20-
description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: cl-02. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)"
20+
description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: prod-0205-icl. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)."
2121

2222
validation {
23-
condition = var.prefix == null || var.prefix == "" ? true : alltrue([
24-
can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), length(regexall("--", var.prefix)) == 0
25-
])
23+
# - null and empty string is allowed
24+
# - Must not contain consecutive hyphens (--): length(regexall("--", var.prefix)) == 0
25+
# - Starts with a lowercase letter: [a-z]
26+
# - Contains only lowercase letters (a–z), digits (0–9), and hyphens (-)
27+
# - Must not end with a hyphen (-): [a-z0-9]
28+
condition = (var.prefix == null || var.prefix == "" ? true :
29+
alltrue([
30+
can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)),
31+
length(regexall("--", var.prefix)) == 0
32+
])
33+
)
2634
error_message = "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--')."
2735
}
2836

2937
validation {
30-
condition = var.prefix == null || var.prefix == "" ? true : length(var.prefix) <= 16
38+
# must not exceed 16 characters in length
39+
condition = length(var.prefix) <= 16
3140
error_message = "Prefix must not exceed 16 characters."
3241
}
3342
}
3443

3544
variable "provider_visibility" {
36-
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)."
3745
type = string
46+
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)."
3847
default = "private"
3948

4049
validation {
@@ -245,7 +254,7 @@ variable "existing_cloud_logs_crn" {
245254

246255
variable "cloud_logs_instance_name" {
247256
type = string
248-
description = "The name of the IBM Cloud Logs instance to create."
257+
description = "The name of the IBM Cloud Logs instance to create. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<instance_name>` format."
249258
default = "cloud-logs"
250259
}
251260

0 commit comments

Comments
 (0)