Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions caf_launchpad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ provider "azurerm" {
partner_id = "ca4078f8-9bc4-471b-ab5b-3af6b86a42c8"
features {
api_management {
purge_soft_delete_on_destroy = var.provider_azurerm_features_api_management.purge_soft_delete_on_destroy
purge_soft_delete_on_destroy = var.provider_azurerm_features_api_management.purge_soft_delete_on_destroy
# recover_soft_deleted_api_managements = var.provider_azurerm_features_api_management.recover_soft_deleted_api_managements
}
# application_insights {
Expand Down Expand Up @@ -83,7 +83,15 @@ resource "random_string" "prefix" {
length = 4
special = false
upper = false
number = false
numeric = false
}

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

locals {
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 Expand Up @@ -134,4 +145,4 @@ locals {

}

data "azurerm_client_config" "current" {}
data "azurerm_client_config" "current" {}
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