-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AZ-515: Option to use Azure CAF naming provider to name resources
- Loading branch information
Showing
10 changed files
with
64 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
variables: | ||
TF_MIN_VERSION: "0.12" | ||
TF_MIN_VERSION: "0.13" | ||
AZURERM_PROVIDER_MIN_VERSION: "2.8.0" | ||
|
||
include: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
locals { | ||
# Naming locals/constants | ||
name_prefix = lower(var.name_prefix) | ||
name_suffix = lower(var.name_suffix) | ||
|
||
subnet_name = coalesce(var.custom_subnet_name, azurecaf_name.subnet.result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "azurecaf_name" "subnet" { | ||
name = var.stack | ||
resource_type = "azurerm_subnet" | ||
prefixes = var.name_prefix == "" ? null : [local.name_prefix] | ||
suffixes = compact([var.client_name, var.location_short, var.environment, local.name_suffix, var.use_caf_naming ? "" : "subnet"]) | ||
use_slug = var.use_caf_naming | ||
clean_input = true | ||
separator = "-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
location_short="frc" | ||
client_name="test" | ||
environment="test" | ||
stack="ci" | ||
resource_group_name="rg-test" | ||
virtual_network_name="vnet-test" | ||
subnet_cidr_list=["10.10.0.0/24"] | ||
service_endpoints=["Microsoft.AzureActiveDirectory","Microsoft.AzureCosmosDB"] | ||
location_short = "frc" | ||
client_name = "test" | ||
environment = "test" | ||
stack = "ci" | ||
resource_group_name = "rg-test" | ||
virtual_network_name = "vnet-test" | ||
subnet_cidr_list = ["10.10.0.0/24"] | ||
service_endpoints = ["Microsoft.AzureActiveDirectory", "Microsoft.AzureCosmosDB"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generic naming variables | ||
variable "name_prefix" { | ||
description = "Optional prefix for the generated name" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "name_suffix" { | ||
description = "Optional suffix for the generated name" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "use_caf_naming" { | ||
description = "Use the Azure CAF naming provider to generate default resource name. `custom_subnet_name` override this if set. Legacy default name is used if this is set to `false`." | ||
type = bool | ||
default = true | ||
} | ||
|
||
# Custom naming override | ||
variable "custom_subnet_name" { | ||
description = "Optional custom subnet name" | ||
type = string | ||
default = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12.26" | ||
required_version = ">= 0.13" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = ">= 2.8.0" | ||
} | ||
azurecaf = { | ||
source = "aztfmod/azurecaf" | ||
version = "~> 1.1" | ||
} | ||
} | ||
} |