Skip to content

Commit 2a9fd8f

Browse files
maheshwarishikhaShikha Maheshwari
andauthored
feat: add DA prefix doc (#76)
* add DA prefix doc * added code snippet in prefix doc * address review comments * address formatting --------- Co-authored-by: Shikha Maheshwari <shikhamaheshwari@Shikhas-MacBook-Pro.local>
1 parent 329970c commit 2a9fd8f

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can see the published documentation at https://terraform-ibm-modules.github.
2323
- [About merging pull requests](https://terraform-ibm-modules.github.io/documentation/#/merging.md)
2424
- Reference
2525
- [Module authoring guidelines](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines.md)
26+
- [Deployable Architecture authoring guidelines](https://terraform-ibm-modules.github.io/documentation/#/da-implementation-guidelines.md)
2627
- [Design guidelines](https://terraform-ibm-modules.github.io/documentation/#/design-guidelines.md)
2728
- [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure.md)
2829
- [Metadata file (index.yml)](https://terraform-ibm-modules.github.io/documentation/#/module-catalog-metadata.md)

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [About merging pull requests](merging.md)
1414
- Reference
1515
- [Module authoring guidelines](implementation-guidelines.md)
16+
- [Deployable Architecture authoring guidelines](da-implementation-guidelines.md)
1617
- [Design guidelines](design-guidelines.md)
1718
- [Module structure](module-structure.md)
1819
- [Metadata file (index.yml)](module-catalog-metadata.md)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Deployable Architecture authoring guidelines
2+
3+
## Prefix in Deployable Architecture
4+
5+
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:
6+
7+
- **Avoiding naming collisions** when deploying the same solution multiple times within the same account.
8+
- **Creating identical infrastructure** across multiple regions or environments.
9+
- **Improving resource traceability** by embedding environment or region identifiers into resource names.
10+
11+
If you do not wish to use a prefix, you may set the value to `null` or an empty string (`""`).
12+
13+
**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.
14+
15+
### Examples
16+
17+
Here are some common patterns for using the prefix:
18+
19+
- **Environment-based**:
20+
- `dev`, `test`, `prod`
21+
- **Environment + Region**:
22+
- `dev-eu-gb`, `prod-us-south`, `test-jp-tok`
23+
- **Project-specific**:
24+
- `webapp-dev`, `ml-prod`, `iot-test`
25+
- **Team or department identifiers**:
26+
- `fin-dev`, `hr-prod`, `eng-test`
27+
- **Date or version-based** (for temporary or experimental deployments):
28+
- `exp-202505`, `v2-dev`
29+
30+
These conventions help ensure that resources are clearly grouped and easily identifiable, especially in shared or multi-tenant accounts.
31+
32+
### Naming Rules
33+
34+
To ensure compatibility and consistency, the prefix must follow these rules:
35+
36+
- Must begin with a **lowercase letter**
37+
- May contain only **lowercase letters**, **digits**, and **hyphens (`-`)**
38+
- Must **not end** with a hyphen (`-`)
39+
- Must **not contain consecutive hyphens** (`--`)
40+
- Maximum length: **16 characters**
41+
42+
Here is the code snippet for your reference.
43+
44+
```hcl
45+
variable "prefix" {
46+
type = string
47+
nullable = true
48+
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."
49+
50+
validation {
51+
# - null and empty string is allowed
52+
# - Must not contain consecutive hyphens (--): length(regexall("--", var.prefix)) == 0
53+
# - Starts with a lowercase letter: [a-z]
54+
# - Contains only lowercase letters (a–z), digits (0–9), and hyphens (-)
55+
# - Must not end with a hyphen (-): [a-z0-9]
56+
condition = (var.prefix == null || var.prefix == "" ? true :
57+
alltrue([
58+
can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)),
59+
length(regexall("--", var.prefix)) == 0
60+
])
61+
)
62+
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 ('--')."
63+
}
64+
65+
validation {
66+
# must not exceed 16 characters in length
67+
condition = length(var.prefix) <= 16
68+
error_message = "Prefix must not exceed 16 characters."
69+
}
70+
}
71+
```

0 commit comments

Comments
 (0)