Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Add suffix option to azurecaf_name resources #407

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions caf_launchpad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ resource "random_string" "prefix" {
number = false
}

resource "random_string" "suffix" {
count = var.suffix == null ? 1 : 0
length = 4
special = false
upper = false
number = false
}

locals {
landingzone_tag = {
"landingzone" = var.landingzone.key
Expand All @@ -101,6 +109,9 @@ locals {
prefix = var.prefix
prefixes = var.prefix == "" ? null : [try(random_string.prefix.0.result, var.prefix)]
prefix_with_hyphen = var.prefix == "" ? null : format("%s", try(random_string.prefix.0.result, var.prefix))
suffix = var.suffix
suffixes = var.suffix == "" ? null : [try(random_string.suffix.0.result, var.suffix)]
suffix_with_hyphen = var.suffix == "" ? null : format("%s", try(random_string.suffix.0.result, var.suffix))
Comment on lines +113 to +114
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether these two could also be useful. Just copied over the idea from the prefix.

random_length = var.random_length
regions = var.regions
tags = var.tags
Expand Down
4 changes: 4 additions & 0 deletions caf_launchpad/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ variable "prefix" {
default = null
}

variable "suffix" {
default = null
}

variable "use_slug" {
default = true
}
Expand Down