Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 58 additions & 0 deletions docs/DA-prefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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**

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."
}
```