From a0d63d60988b39bb522f2d3b41dad0274ed601c8 Mon Sep 17 00:00:00 2001 From: Shikha Maheshwari Date: Mon, 12 May 2025 13:11:58 +0530 Subject: [PATCH 1/4] add DA prefix doc --- README.md | 2 ++ docs/DA-prefix.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 docs/DA-prefix.md diff --git a/README.md b/README.md index cc8df14..289d325 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ You can see the published documentation at https://terraform-ibm-modules.github. - Maintaining the GitHub project - [Maintainers contribution process](https://terraform-ibm-modules.github.io/documentation/#/maintain-module.md) - [About merging pull requests](https://terraform-ibm-modules.github.io/documentation/#/merging.md) +- Deployable Architecture Reference Docs + - [Prefix Usage Guide](https://terraform-ibm-modules.github.io/documentation/#/DA-prefix.md) - Reference - [Module authoring guidelines](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines.md) - [Design guidelines](https://terraform-ibm-modules.github.io/documentation/#/design-guidelines.md) diff --git a/docs/DA-prefix.md b/docs/DA-prefix.md new file mode 100644 index 0000000..822c7d1 --- /dev/null +++ b/docs/DA-prefix.md @@ -0,0 +1,38 @@ +# Prefix in Deployable Architecture + +The **`prefix`** input variable allows you to prepend a custom string to the names of all resources created by this automation. This is especially useful for: + +- **Avoiding naming collisions** when deploying the same solution multiple times within the same account. +- **Creating identical infrastructure** across multiple regions or environments. +- **Improving resource traceability** by embedding environment or region identifiers into resource names. + +If you do not wish to use a prefix, you may set the value to `null` or an empty string (`""`). + +**Important**: The automation automatically inserts a hyphen between the prefix and the resource name. Therefore, you do not need to include a hyphen in the prefix yourself. + +### Examples + +Here are some common patterns for using the prefix: + +- **Environment-based**: + - `dev`, `test`, `prod` +- **Environment + Region**: + - `dev-eu-gb`, `prod-us-south`, `test-jp-tok` +- **Project-specific**: + - `webapp-dev`, `ml-prod`, `iot-test` +- **Team or department identifiers**: + - `fin-dev`, `hr-prod`, `eng-test` +- **Date or version-based** (for temporary or experimental deployments): + - `exp-202505`, `v2-dev` + +These conventions help ensure that resources are clearly grouped and easily identifiable, especially in shared or multi-tenant accounts. + +### Naming Rules + +To ensure compatibility and consistency, the prefix must follow these rules: + +- Must begin with a **lowercase letter** +- May contain only **lowercase letters**, **digits**, and **hyphens (`-`)** +- Must **not end** with a hyphen (`-`) +- Must **not contain consecutive hyphens** (`--`) +- Maximum length: **16 characters** From a552fa464c600b8afc737cd4fd2e6b2346edb3ed Mon Sep 17 00:00:00 2001 From: Shikha Maheshwari Date: Thu, 15 May 2025 13:49:45 +0530 Subject: [PATCH 2/4] added code snippet in prefix doc --- docs/DA-prefix.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/DA-prefix.md b/docs/DA-prefix.md index 822c7d1..5948c0a 100644 --- a/docs/DA-prefix.md +++ b/docs/DA-prefix.md @@ -36,3 +36,23 @@ To ensure compatibility and consistency, the prefix must follow these rules: - Must **not end** with a hyphen (`-`) - Must **not contain consecutive hyphens** (`--`) - Maximum length: **16 characters** + +Here is the code snippet for your reference. + +```hcl +validation { + condition = (var.prefix == null || var.prefix == "" ? true : + alltrue([ + can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), + length(regexall("--", var.prefix)) == 0 + ]) + ) + 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 ('--')." + } + + validation { + # must not exceed 16 characters in length + condition = length(var.prefix) <= 16 + error_message = "Prefix must not exceed 16 characters." + } +``` \ No newline at end of file From 519ca9e8b206c37157b651bcdcf8d2d6c115ebe0 Mon Sep 17 00:00:00 2001 From: Shikha Maheshwari Date: Thu, 15 May 2025 20:17:43 +0530 Subject: [PATCH 3/4] address review comments --- README.md | 3 +-- docs/_sidebar.md | 1 + ...fix.md => da-implementation-guidelines.md} | 20 +++++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) rename docs/{DA-prefix.md => da-implementation-guidelines.md} (72%) diff --git a/README.md b/README.md index 289d325..cdf9c40 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,9 @@ You can see the published documentation at https://terraform-ibm-modules.github. - Maintaining the GitHub project - [Maintainers contribution process](https://terraform-ibm-modules.github.io/documentation/#/maintain-module.md) - [About merging pull requests](https://terraform-ibm-modules.github.io/documentation/#/merging.md) -- Deployable Architecture Reference Docs - - [Prefix Usage Guide](https://terraform-ibm-modules.github.io/documentation/#/DA-prefix.md) - Reference - [Module authoring guidelines](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines.md) + - [Deployable Architecture authoring guidelines](https://terraform-ibm-modules.github.io/documentation/#/da-implementation-guidelines.md) - [Design guidelines](https://terraform-ibm-modules.github.io/documentation/#/design-guidelines.md) - [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure.md) - [Metadata file (index.yml)](https://terraform-ibm-modules.github.io/documentation/#/module-catalog-metadata.md) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 7ef3163..e5dd769 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -13,6 +13,7 @@ - [About merging pull requests](merging.md) - Reference - [Module authoring guidelines](implementation-guidelines.md) + - [Deployable Architecture authoring guidelines](da-implementation-guidelines.md) - [Design guidelines](design-guidelines.md) - [Module structure](module-structure.md) - [Metadata file (index.yml)](module-catalog-metadata.md) diff --git a/docs/DA-prefix.md b/docs/da-implementation-guidelines.md similarity index 72% rename from docs/DA-prefix.md rename to docs/da-implementation-guidelines.md index 5948c0a..0a34ff6 100644 --- a/docs/DA-prefix.md +++ b/docs/da-implementation-guidelines.md @@ -1,4 +1,6 @@ -# Prefix in Deployable Architecture +# Deployable Architecture authoring guidelines + +## Prefix in Deployable Architecture The **`prefix`** input variable allows you to prepend a custom string to the names of all resources created by this automation. This is especially useful for: @@ -40,7 +42,17 @@ To ensure compatibility and consistency, the prefix must follow these rules: Here is the code snippet for your reference. ```hcl -validation { +variable "prefix" { + type = string + nullable = true + 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-cos." + + validation { + # - null and empty string is allowed + # - Must not contain consecutive hyphens (--): length(regexall("--", var.prefix)) == 0 + # - Starts with a lowercase letter: [a-z] + # - Contains only lowercase letters (a–z), digits (0–9), and hyphens (-) + # - Must not end with a hyphen (-): [a-z0-9] condition = (var.prefix == null || var.prefix == "" ? true : alltrue([ can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), @@ -49,10 +61,10 @@ validation { ) 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 ('--')." } - validation { # must not exceed 16 characters in length condition = length(var.prefix) <= 16 error_message = "Prefix must not exceed 16 characters." - } + } +} ``` \ No newline at end of file From 92ebc6d92bd2dceea07ba6678b6a944bb63c558f Mon Sep 17 00:00:00 2001 From: Shikha Maheshwari Date: Thu, 15 May 2025 20:20:36 +0530 Subject: [PATCH 4/4] address formatting --- docs/da-implementation-guidelines.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/da-implementation-guidelines.md b/docs/da-implementation-guidelines.md index 0a34ff6..fd33cab 100644 --- a/docs/da-implementation-guidelines.md +++ b/docs/da-implementation-guidelines.md @@ -61,6 +61,7 @@ variable "prefix" { ) 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 ('--')." } + validation { # must not exceed 16 characters in length condition = length(var.prefix) <= 16