Giter Site home page Giter Site logo

terraform-azurerm-naming's Introduction

Azure Naming

This module helps you to keep consistency on your resources names for Terraform The goal of this module it is that for each resource that requires a name in Terraform you would be easily able to compose this name using this module and this will keep the consistency in your repositories.

Usage

For every resource in terraform_azurerm just remove the azurerm part of the module and use the name property of this output.

example for azurerm_resource_group you can use :

module "naming" {
  source  = "Azure/naming/azurerm"
  suffix = [ "test" ]
}
resource "azurerm_resource_group" "example" {
  name     = module.naming.resource_group.name
  location = "West Europe"
}

if you want this to be unique for this module and not shared with other instances of this module you can use name_unique

module "naming" {
  source  = "Azure/naming/azurerm"
  suffix = [ "test" ]
}
resource "azurerm_resource_group" "example" {
  name     = module.naming.resource_group.name_unique
  location = "West Europe"
}

Other advanced usages will be explained in the Advanced usage part of this docs.

Internals

Prerequisites and setup

  • Install tflint as suitable for your OS.

  • Run make install in the root directory of the repo.

Modifying resources

The resources are automatically generated using go to change the generation please change the file on the templates folder. To add a new resource, including its definition in the file resourceDefinition.json, and it will be automatically generated when main.go is run.

Current implementation

You can find a list bellow of all the resources that are currently implemented. To get a list of the ones that are missing implementation you can check at Missing resources the resources that have no documentation about their limitation on naming currently on Microsoft docs are on the Not defined list.

Advanced usage

Output

Each one of the resources emits the name of the resource and other properties:

Property Type Description
name string name of the resource including respective suffixes and prefixes applied
name_unique string same as the name but with random chars added for uniqueness
dashes bool if these resources support dashes
slug string letters to identify this resource among others
min_length integer Minimum length required for this resource name
max_length integer Maximum length allowed for this resource name
scope string scope which this name needs to be unique, such as resourcegroup or global
regex string Terraform compatible version of the regex

Example Output

Every resource will have an output with the following format:

postgresql_server = {
      name        = "pre-fix-psql-su-fix"
      name_unique = "pre-fix-psql-su-fix-asdfg"
      dashes      = true
      slug        = "psql"
      min_length  = 3
      max_length  = 63
      scope       = "global"
      regex       = "^[a-z0-9][a-zA-Z0-9-]+[a-z0-9]$"
    }

Requirements

Name Version
random >= 3.3.2

Providers

Name Version
random >= 3.3.2

Modules

No modules.

Resources

Name Type
random_string.first_letter resource
random_string.main resource

Inputs

Name Description Type Default Required
prefix It is not recommended that you use prefix by azure you should be using a suffix for your resources. list(string) [] no
suffix It is recommended that you specify a suffix for consistency. please use only lowercase characters when possible list(string) [] no
unique-include-numbers If you want to include numbers in the unique generation bool true no
unique-length Max length of the uniqueness suffix to be added number 4 no
unique-seed Custom value for the random characters to be used string "" no

Outputs

Name Description
analysis_services_server Analysis Services Server
api_management Api Management
app_configuration App Configuration
app_service App Service
app_service_environment n/a
app_service_plan App Service Plan
application_gateway Application Gateway
application_insights Application Insights
application_security_group Application Security Group
automation_account Automation Account
automation_certificate Automation Certificate
automation_credential Automation Credential
automation_runbook Automation Runbook
automation_schedule Automation Schedule
automation_variable Automation Variable
availability_set Availability Set
bastion_host Bastion Host
batch_account Batch Account
batch_application Batch Application
batch_certificate Batch Certificate
batch_pool Batch Pool
bot_channel_directline Bot Channel Directline
bot_channel_email Bot Channel Email
bot_channel_ms_teams Bot Channel Ms Teams
bot_channel_slack Bot Channel Slack
bot_channels_registration Bot Channels Registration
bot_connection Bot Connection
bot_web_app Bot Web App
cdn_endpoint Cdn Endpoint
cdn_profile Cdn Profile
cognitive_account Cognitive Account
container_app Container App
container_app_environment Container App Environment
container_group Container Group
container_registry Container Registry
container_registry_webhook Container Registry Webhook
cosmosdb_account Cosmosdb Account
cosmosdb_cassandra_cluster Cosmosdb Cassandra Cluster
cosmosdb_cassandra_datacenter Cosmosdb Cassandra Datacenter
cosmosdb_postgres Cosmosdb Postgres
custom_provider Custom Provider
dashboard Dashboard
data_factory Data Factory
data_factory_dataset_mysql Data Factory Dataset Mysql
data_factory_dataset_postgresql Data Factory Dataset Postgresql
data_factory_dataset_sql_server_table Data Factory Dataset Sql Server Table
data_factory_integration_runtime_managed Data Factory Integration Runtime Managed
data_factory_linked_service_data_lake_storage_gen2 Data Factory Linked Service Data Lake Storage Gen2
data_factory_linked_service_key_vault Data Factory Linked Service Key Vault
data_factory_linked_service_mysql Data Factory Linked Service Mysql
data_factory_linked_service_postgresql Data Factory Linked Service Postgresql
data_factory_linked_service_sql_server Data Factory Linked Service Sql Server
data_factory_pipeline Data Factory Pipeline
data_factory_trigger_schedule Data Factory Trigger Schedule
data_lake_analytics_account Data Lake Analytics Account
data_lake_analytics_firewall_rule Data Lake Analytics Firewall Rule
data_lake_store Data Lake Store
data_lake_store_firewall_rule Data Lake Store Firewall Rule
database_migration_project Database Migration Project
database_migration_service Database Migration Service
databricks_cluster Databricks Cluster
databricks_high_concurrency_cluster Databricks High Concurrency Cluster
databricks_standard_cluster Databricks Standard Cluster
databricks_workspace Databricks Workspace
dev_test_lab Dev Test Lab
dev_test_linux_virtual_machine Dev Test Linux Virtual Machine
dev_test_windows_virtual_machine Dev Test Windows Virtual Machine
disk_encryption_set Disk Encryption Set
dns_a_record Dns A Record
dns_aaaa_record Dns Aaaa Record
dns_caa_record Dns Caa Record
dns_cname_record Dns Cname Record
dns_mx_record Dns Mx Record
dns_ns_record Dns Ns Record
dns_ptr_record Dns Ptr Record
dns_txt_record Dns Txt Record
dns_zone Dns Zone
eventgrid_domain Eventgrid Domain
eventgrid_domain_topic Eventgrid Domain Topic
eventgrid_event_subscription Eventgrid Event Subscription
eventgrid_topic Eventgrid Topic
eventhub Eventhub
eventhub_authorization_rule Eventhub Authorization Rule
eventhub_consumer_group Eventhub Consumer Group
eventhub_namespace Eventhub Namespace
eventhub_namespace_authorization_rule Eventhub Namespace Authorization Rule
eventhub_namespace_disaster_recovery_config Eventhub Namespace Disaster Recovery Config
express_route_circuit Express Route Circuit
express_route_gateway Express Route Gateway
firewall Firewall
firewall_application_rule_collection Firewall Application Rule Collection
firewall_ip_configuration Firewall Ip Configuration
firewall_nat_rule_collection Firewall Nat Rule Collection
firewall_network_rule_collection Firewall Network Rule Collection
firewall_policy Firewall Policy
firewall_policy_rule_collection_group Firewall Policy Rule Collection Group
frontdoor Frontdoor
frontdoor_firewall_policy Frontdoor Firewall Policy
function_app Function App
hdinsight_hadoop_cluster Hdinsight Hadoop Cluster
hdinsight_hbase_cluster Hdinsight Hbase Cluster
hdinsight_interactive_query_cluster Hdinsight Interactive Query Cluster
hdinsight_kafka_cluster Hdinsight Kafka Cluster
hdinsight_ml_services_cluster Hdinsight Ml Services Cluster
hdinsight_rserver_cluster Hdinsight Rserver Cluster
hdinsight_spark_cluster Hdinsight Spark Cluster
hdinsight_storm_cluster Hdinsight Storm Cluster
image Image
iotcentral_application Iotcentral Application
iothub Iothub
iothub_consumer_group Iothub Consumer Group
iothub_dps Iothub Dps
iothub_dps_certificate Iothub Dps Certificate
key_vault Key Vault
key_vault_certificate Key Vault Certificate
key_vault_key Key Vault Key
key_vault_secret Key Vault Secret
kubernetes_cluster Kubernetes Cluster
kusto_cluster Kusto Cluster
kusto_database Kusto Database
kusto_eventhub_data_connection Kusto Eventhub Data Connection
lb Lb
lb_nat_rule Lb Nat Rule
linux_virtual_machine Linux Virtual Machine
linux_virtual_machine_scale_set Linux Virtual Machine Scale Set
local_network_gateway Local Network Gateway
log_analytics_workspace Log Analytics Workspace
logic_app_workflow Logic App Workflow
machine_learning_workspace Machine Learning Workspace
managed_disk Managed Disk
maps_account Maps Account
mariadb_database Mariadb Database
mariadb_firewall_rule Mariadb Firewall Rule
mariadb_server Mariadb Server
mariadb_virtual_network_rule Mariadb Virtual Network Rule
monitor_action_group Monitor Action Group
monitor_autoscale_setting Monitor Autoscale Setting
monitor_diagnostic_setting Monitor Diagnostic Setting
monitor_scheduled_query_rules_alert Monitor Scheduled Query Rules Alert
mssql_database Mssql Database
mssql_elasticpool Mssql Elasticpool
mssql_managed_instance Mssql Server Managed Instance
mssql_server Mssql Server
mysql_database Mysql Database
mysql_firewall_rule Mysql Firewall Rule
mysql_server Mysql Server
mysql_virtual_network_rule Mysql Virtual Network Rule
nat_gateway NAT Gateway
network_ddos_protection_plan Network Ddos Protection Plan
network_interface Network Interface
network_security_group Network Security Group
network_security_group_rule Network Security Group Rule
network_security_rule Network Security Rule
network_watcher Network Watcher
notification_hub Notification Hub
notification_hub_authorization_rule Notification Hub Authorization Rule
notification_hub_namespace Notification Hub Namespace
point_to_site_vpn_gateway Point To Site Vpn Gateway
postgresql_database Postgresql Database
postgresql_firewall_rule Postgresql Firewall Rule
postgresql_server Postgresql Server
postgresql_virtual_network_rule Postgresql Virtual Network Rule
powerbi_embedded Powerbi Embedded
private_dns_a_record Private Dns A Record
private_dns_aaaa_record Private Dns Aaaa Record
private_dns_cname_record Private Dns Cname Record
private_dns_mx_record Private Dns Mx Record
private_dns_ptr_record Private Dns Ptr Record
private_dns_srv_record Private Dns Srv Record
private_dns_txt_record Private Dns Txt Record
private_dns_zone Private Dns Zone
private_dns_zone_group Private Dns Zone Group
private_endpoint Private Endpoint
private_link_service Private Link Service
private_service_connection Private Service Connection
proximity_placement_group Proximity Placement Group
public_ip Public Ip
public_ip_prefix Public Ip Prefix
recovery_services_vault Recovery Services Vault
redis_cache Redis Cache
redis_firewall_rule Redis Firewall Rule
relay_hybrid_connection Relay Hybrid Connection
relay_namespace Relay Namespace
resource_group Resource Group
role_assignment Role Assignment
role_definition Role Definition
route Route
route_table Route Table
search_service Search Service
service_fabric_cluster Service Fabric Cluster
servicebus_namespace Servicebus Namespace
servicebus_namespace_authorization_rule Servicebus Namespace Authorization Rule
servicebus_queue Servicebus Queue
servicebus_queue_authorization_rule Servicebus Queue Authorization Rule
servicebus_subscription Servicebus Subscription
servicebus_subscription_rule Servicebus Subscription Rule
servicebus_topic Servicebus Topic
servicebus_topic_authorization_rule Servicebus Topic Authorization Rule
shared_image Shared Image
shared_image_gallery Shared Image Gallery
signalr_service Signalr Service
snapshots Snapshots
sql_elasticpool Sql Elasticpool
sql_failover_group Sql Failover Group
sql_firewall_rule Sql Firewall Rule
sql_server Sql Server
storage_account Storage Account
storage_blob Storage Blob
storage_container Storage Container
storage_data_lake_gen2_filesystem Storage Data Lake Gen2 Filesystem
storage_queue Storage Queue
storage_share Storage Share
storage_share_directory Storage Share Directory
storage_table Storage Table
stream_analytics_function_javascript_udf Stream Analytics Function Javascript Udf
stream_analytics_job Stream Analytics Job
stream_analytics_output_blob Stream Analytics Output Blob
stream_analytics_output_eventhub Stream Analytics Output Eventhub
stream_analytics_output_mssql Stream Analytics Output Mssql
stream_analytics_output_servicebus_queue Stream Analytics Output Servicebus Queue
stream_analytics_output_servicebus_topic Stream Analytics Output Servicebus Topic
stream_analytics_reference_input_blob Stream Analytics Reference Input Blob
stream_analytics_stream_input_blob Stream Analytics Stream Input Blob
stream_analytics_stream_input_eventhub Stream Analytics Stream Input Eventhub
stream_analytics_stream_input_iothub Stream Analytics Stream Input Iothub
subnet Subnet
template_deployment Template Deployment
traffic_manager_profile Traffic Manager Profile
unique-seed n/a
user_assigned_identity User Assigned Identity
validation n/a
virtual_desktop_application_group Virtual Desktop Application Group
virtual_desktop_host_pool Virtual Desktop Host Pool
virtual_desktop_scaling_plan Virtual Desktop Scaling Plan
virtual_desktop_workspace Virtual Desktop Workspace
virtual_machine Virtual Machine
virtual_machine_extension Virtual Machine Extension
virtual_machine_scale_set Virtual Machine Scale Set
virtual_machine_scale_set_extension Virtual Machine Scale Set Extension
virtual_network Virtual Network
virtual_network_gateway Virtual Network Gateway
virtual_network_gateway_connection Virtual Network Gateway Connection
virtual_network_peering Virtual Network Peering
virtual_wan Virtual Wan
windows_virtual_machine Windows Virtual Machine
windows_virtual_machine_scale_set Windows Virtual Machine Scale Set
static_web_app Static Web App

Contributing Guidelines

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

terraform-azurerm-naming's People

Contributors

argonqq avatar basvdl avatar catay avatar cdhunt avatar daniel-anova avatar devblackops avatar diego-souza-xpandit avatar eklipzgit avatar ferrydg avatar horizonnet avatar jdompablo avatar jesseward avatar jjcollinge avatar kkondratev avatar laurentlesle avatar lukedevs avatar masoncusack avatar microsoftopensource avatar nepomuceno avatar nils-woxholt avatar nithinmohantk avatar pearcec avatar pierca7 avatar puneetgared avatar rjcooney avatar ryanwang2 avatar stevehaigh avatar sujithq avatar technicallyjoe avatar travisty- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azurerm-naming's Issues

How to apply MS recommended naming conventions?

I'm currently looking into naming conventions and much appreciate your work on this module. Having an automated solution for naming resources would be great. However, I'm currently running into an issue that I cannot seem to solve with the existing suffix input.

Here are a couple of recommendations from https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging

Virtual network: vnet-<Subscription type>-<Region>-<###>     
Example: vnet-prod-westus-001

Storage account (general use): st<storage name><###>
Example: stnavigatordata001

Your module generates the prefix and adds the defined suffix (e.g. vnet-prod), but I haven't figured out how to add the different recommended name parts as per Microsoft and also the running count at the end. If I add them outside of the module's control, the name length validation no longer works.
What am I missing? Thanks!

Multiple resource - Loop

Hello,
Thanks for sharing the module. We are trying to create multiple resources at the same time and we were wondering if there is any update to module or methods where we can create multiple resources using the module.

Module returns wrong name format for Storage Account and Shared Image Gallery

I have tried changing the module from true to false but the issue remains

code: -

resource "azurerm_storage_account" "core" {
  name                      = lower(module.naming.storage_account.name)
  resource_group_name       = azurerm_resource_group.core.name
  location                  = azurerm_resource_group.core.location
  account_tier              = "Standard"
  account_replication_type  = "LRS"
}

error: -

Terraform planned the following actions, but then encountered a problem:

  azurerm_resource_group.core will be created
  + resource "azurerm_resource_group" "core" {
      + id       = (known after apply)
      + location = "uksouth"
      + name     = "rg-core-uks"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Error: name ("stcore-uks") can only consist of lowercase letters and numbers, and must be between 3 and 24 characters long
│
│   with azurerm_storage_account.core,
│   on main.tf line 16, in resource "azurerm_storage_account" "core":
│   16:   name                     = lower(module.naming.storage_account.name)
│

How to crate multiple resources in with name_unique

Hi Team,

I like to create multiple resources with name_unique method, When I try apply I can see one resouce_group created .

module "naming" {
  source  = "Azure/naming/azurerm"
  suffix  = ["prod", "app1"]
  unique-include-numbers = true
}

resource "azurerm_resource_group" "example" {
  name     = module.naming.resource_group.name_unique
  location = "West Europe"
}


resource "azurerm_resource_group" "example1" {
  name     = module.naming.resource_group.name_unique
  location = "West Europe"
}

Incorrect slug and name returned for bastion_host

The bastion_host was expected to return "bas" as the slug, but is returning "snap". Likely a copy and paste error. Snippet from main.tf below:

    bastion_host = {
      name        = substr(join("-", compact([local.prefix, "snap", local.suffix])), 0, 80)
      name_unique = substr(join("-", compact([local.prefix, "snap", local.suffix_unique])), 0, 80)
      dashes      = true
      slug        = "snap"
      min_length  = 1
      max_length  = 80
      scope       = "parent"
      regex       = "^[a-zA-Z0-9][a-zA-Z0-9-._]+[a-zA-Z0-9_]$"
    }

cosmosdb_account

CosmosDB account has to be lowercase and if I use this module it was giving error because account name has to be lowercase.
"name": "cosmosdb_account",
"regex": "^(?=.{1,63}$)[a-z0-9][a-zA-Z0-9-_.]+[a-zA-Z0-9]$"

CDKTF examples using typescript

Hi,

I'm not pro with CDKTF. Tying to leverage the module you created in CDKTF project with Typescript.

The simple resource group in azure is not generated using the below generated code

import { Naming } from "./.gen/modules/Azure/azurerm/naming";

const infraNaming = new Naming(this,"infraNaming",{
suffix : ["temp"],
uniqueLength : 6
})

new ResourceGroup(this, "coreGroup", {
name: infraNaming.resourceGroupOutput,
location: defaultLocation,
});

the value of infraNaming.resourceGroupOutput --> ${TfToken[TOKEN.0]} this is not correct.

the HCL generated (removed most of code)

"resource": {
"azurerm_resource_group": {
"coreGroup": {
"//": {
"metadata": {
"path": "portal-ts/coreGroup",
"uniqueId": "coreGroup"
}
},
"location": "northeurope",
"name": "${module.infraNaming.resource_group}"
}
}
},

Which as per documentation as to be some existing property like 'name' or uniqe-name

in Typescript those properties are not generated to be used.

module.infraNaming.resource_group is object with 8 attributes

Inappropriate value for attribute "name": string required.

Is the module compatible with CDKTF?

Hi,

I'm trying to leverage the module using CDKTF and c#, but it seems the names are not generated or I'm missing something?

Error: Incorrect attribute value type

│ on cdk.tf.json line 62, in resource.azurerm_resource_group.CoreResourceGroup:
│ 62: "name": "${module.stacknaming.resource_group}",
│ ├────────────────
│ │ module.stacknaming.resource_group is object with 8 attributes

│ Inappropriate value for attribute "name": string required.

usage
var projectNaming = new Naming(this,"stack naming",new NamingOptions {
Suffix = new string[] {"myapp"}
});

projectNaming.ResourceGroupOutput

I do not see 'name' property as described here

https://github.com/Azure/terraform-azurerm-naming#usage

my CDKTF.json

"terraformModules": [{
"name": "naming",
"source": "Azure/naming/azurerm",
"version": "0.1.0"
}],

frontdoor_firewall_policy producing invalid output

The name value for an azurerm_cdn_frontdoor_firewall_policy does not support dashes - only letters and numbers. The module generates the outputs with dashes concatenating the various inputs.

╷
│ Error: "name" did not match regex "(^[a-zA-Z])([\\da-zA-Z]{0,127})$"
│
│   with module.appservice.azurerm_cdn_frontdoor_firewall_policy.global["ui-staging"],
│   on module\main.tf line 475, in resource "azurerm_cdn_frontdoor_firewall_policy" "global":
│  475:   name                              = each.value.waf_policy_name
│
╵

The value of "each.value.waf_policy_name" was generated with the naming module version 0.2.0...

module "naming" {
  source  = "Azure/naming/azurerm"
  version = "0.2.0"

  suffix = [var.project_name]
}

additional property name

Hi,
first of all. I like this module. I just have a wish for future.
Is it possible to implement a property name, which will be cut at the end, to fit with all prefixes and or suffixesand type, that it fits to the max length?

Best regards
s.Kelso

log analytics workspace naming

The module uses 'log' for log analytics workspace but requires a minimum of 4 letters for LAW naming. Is it possible to change the module to a minimum for 4 letters so the deployment doesn't fail?

Nested Provider Configuration not Reflected in Release

I noticed on the latest master branch, you have removed the nested provider configuration. Can you release a new version so that I can use the module without the nested provider configuration?

Initializing modules...
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Module does not support depends_on

  on .terraform/modules/data_factory/key-vault.tf line 11, in module "key_vault":
  11:   source = "git::[email protected]:v3/AZBlue/OneAZBlue/terraform.devops.key-vault?ref=v1.1.0"

Module "key_vault" cannot be used with depends_on because it contains a nested
provider configuration for "random", at
.terraform/modules/data_factory.key_vault.naming/main.tf:1,10-18.

This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.

0.1.0

provider "random" {
  version = "~> 2.2"
}

master

terraform {
  required_providers {
    random = {
      source  = "hashicorp/random"
      version = "~> 2.2"
    }
  }
}

How can I use that one above from master? There are currently no releases that point to that code, no alpha or beta or other release. I appreciate this module and use it heavily at my job, thank you.

Incorrect slug for 'app_configuration'

According to the latest recommended abbreviations, app_configuration should use appcs-, rather than the currently utilised appcg-.

{
    "name": "app_configuration",
    "length": {
      "min": 5,
      "max": 50
    },
    "regex": "^(?=.{5,50}$)[a-zA-Z0-9_-]+$",
    "scope": "resourceGroup",
    "slug": "appcg", // Should be "appcs"
    "dashes": true
  },

Request: Include location in naming

Can you include the location as a 3 or 4 letter abbreviation? It has to be check how many letters are required to make all locations unique.

Expected behavior
Add an option to module configuration location, e.g.

module "naming" {
  source = "Azure/naming/azurerm"
#...
  prefix = "hello"
  location = "westus2"
#...
}

So the generated module.naming.resource_group.name is "hello-rg-wu2" (format "[prefix]-[resource-type]-[location]-[suffix]-[unique]"). For global resources to be consistent I suggest to use an abbreviation as well, or leave it empty. Maybe the community has an opinion on that.

Random provider - deprecated number parameter

As of version 3.3 the terraform-provider-random provider deprecated the "number" paramenter on
resource/random_password and resource/random_string.

This affects line 14 of main.tf.
May also consider changing var.unique-include-numbers to var.unique-include-numeric to match the change they are implementing.

This is now producing warnings on every plan/apply:

Warning: Argument is deprecated

│ with module.naming.random_string.main,
│ on .terraform\modules\naming\main.tf line 14, in resource "random_string" "main":
│ 14: number = var.unique-include-numbers

│ Use numeric instead.

Add support for eventhub_cluster

Hi

Requesting support for eventhub_cluster please 🙏🏼

╷
│ Error: Unsupported attribute
│ 
│   on ../eventhub/cluster.tf line 2, in resource "azurerm_eventhub_cluster" "cluster":2:   name                = var.naming.eventhub_cluster.name
│     ├────────────────
│     │ var.naming is object with 238 attributes
│ 
│ This object does not have an attribute named "eventhub_cluster".

azurerm_virtual_desktop_host_pool & azurerm_virtual_desktop_application_group missing

Hey Guys its me again,

I really enjoyed the module and still do. The only problem I stumbled across the other day is the category of Azure Virtual Desktops.

There is no prefix provided and I am personally a bid unsure how naming could look like. My thoughts currently look like:

terraform: azurerm_virtual_desktop_host_pool
naming module prefix: vdhp

terraform: azurerm_virtual_desktop_application_group
naming module prefix: vdag

terraform: azurerm_virtual_desktop_workspace
naming module prefix: vdw

Maybe we can bake that in? Would love it!

Thanks! 🚀

bastion_host get the wrong slug

  {
    "name": "bastion_host",
    "length": {
      "min": 1,
      "max": 80
    },
    "regex": "^(?=.{1,80}$)[a-zA-Z0-9][a-zA-Z0-9-._]+[a-zA-Z0-9_]$",
    "scope": "parent",
    "slug": "snap",     <--- here
    "dashes": true
  }

Is this being actively maintained?

Having a few issues here and there, most of which are solved by already existing PRs and issues.

We use this module quite extensively to ensure naming standards so i wanna see it updated.

Let me know if i can be of any assistance.

Go dep issues

Running in vscode. Using devcontainer GO 1.16. I tried to sort this out but couldn't. Would be nice to include a working .devcontainer for easy building. I ended up build #55 by hand.

# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
/go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
/go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
/go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
/go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
make: *** [Makefile:8: install] Error 2

Support app_service and application_service_plan

Any reason why these are not included here?

I see them mentioned in the docs/defined_specs as:
app_service_plan = "plan"
web_app = "app"

Although a web_app refers to TF resource "azurerm_app_service" so should be called app_service?

If they are missing, I'll go ahead and add them :)

Shared Image Gallery returned 'dashes' except after the 'slug'

Based on resourceDefinition.json, the azurerm_shared_image_gallery resource should set dashes to false.

  {
    "name": "shared_image_gallery",
    "length": {
      "min": 1,
      "max": 80
    },
    "regex": "^(?=.{1,80}$)[a-zA-Z0-9][a-zA-Z0-9.]+[a-zA-Z0-9]$",
    "scope": "resourceGroup",
    "slug": "sig",
    "dashes": false
  },

However, in the screenshot below, you see dashes included in the output. You will also notice there is no dash/underscore after the slug.

image

Illegal Characters, Name ends with Hyphen

Just so happens that a substring for a key vault had left a hyphen at the end of the name, apparently this is not allowed...

Error: Error creating Key Vault "kv-keyvault-integration-" (Resource Group "rg-keyvault-integration-uks"): keyvault.VaultsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="VaultNameNotValid" Message="Vault name must be between 3-24 alphanumeric characters. The name must begin with a letter, end with a letter or digit, and not contain consecutive hyphens."

for reference the full name would have been 'kv-keyvault-integration-uks'
using this configuration for the module
`variable "env_name" {
type = string
default = "integration"
}

variable "location_short" {
type = string
default = "uks"
}

module "naming-keyvault" {
source = "Azure/naming/azurerm"

suffix = ["keyvault", var.env_name, var.location_short]
}`

Maybe this module should strip illegal trailing characters too

Naming Convention for multiple resource creation in a resource block

Hi Team,

Im playing around with the naming convention module. Im trying to create simple resource groups with for_each loop condition as follows.

module "naming" {
source = "../../modules/naming"
prefix = ["test"]
suffix = ["001", "002"]
}
resource "azurerm_resource_group" "this" {
for_each = var.resource_groups
name = module.naming.resource_group.name #each.value["name"]
location = each.value["location"]
tags = each.value["tags"]
}

after im running the terraform plan im getting following output
-/+ resource "azurerm_resource_group" "this" {
~ id = "/subscriptions/5e3e3b47-32e6-4a47-a96e-028bc54c394a/resourceGroups/rg-wiyo" -> (known after apply)
~ name = "rg-wiyo" -> "test-rg-001-002" # forces replacement
tags = {
"costcode" = "12345678"
"environment" = "test"
}
# (1 unchanged attribute hidden)
}

module.azurerm_resource_group.azurerm_resource_group.this["rg2"] must be replaced

-/+ resource "azurerm_resource_group" "this" {
~ id = "/subscriptions/5e3e3b47-32e6-4a47-a96e-028bc54c394a/resourceGroups/rg-wiyo" -> (known after apply)
~ name = "rg-wiyo" -> "test-rg-001-002" # forces replacement
tags = {
"costcode" = "12345678"
"environment" = "test"
}
# (1 unchanged attribute hidden)
}
what will be the logic we need to use if we want to generate unique name for each resoruce groups as test-rg-001 and test-rg-002

Add support for ssh_public_key resource

There is no support for ssh_public_key:

│ Error: Unsupported attribute
│ 
│   on main.tf line 7, in output "name":
│    7:   value = module.naming.ssh_public_key.name
│     ├────────────────
│     │ module.naming is a object
│ 
│ This object does not have an attribute named "ssh_public_key".

Module "name" cannot be used with depends_on because it contains a nested provider configuration

I have aznaming module inside a module, which depends_on another module to ensure the provisioning order. Terraform gives me the following error as you can't use depends_on with nested modules

Module "blueprism_rpas" cannot be used with depends_on because it contains a
nested provider configuration for "random", at
.terraform\modules\blueprism_rpas.naming\main.tf:1,10-18.

This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.

Is there a way to avoid the error about nested modules? Can I provide providers to module block somehow for aznaming?

Question: why no tags or releases since 0.1.0?

Can you update the version in the terraform repository, or at least tag master once in a while?

Once upon a time, there was a release (0.1.0) made to the terraform repository, and many terraform users were using it like this:

module "naming" {
  source = "Azure/naming/azurerm"
  ...
}

When terraform 0.14 came out, it deprecated version constraints, which causes warnings for anyone that's using this module from the terraform repository.

Of course, that version constraint is fixed here in the repo --and there are also a lot of new resource types-- but the only way we can currently take advantage of that is to use source = "github.com/azure/terraform-azurerm-naming" without even a tagged version...

Azure Container Registry Naming

Hello,

while we're extending our infrastructure with the naming module we stumbled across the Azure Container Registry Naming. Me personally the cr would have been fine but for the Azure CLI its called acr and therefore it is not really convenient to use and also confusing. Is it possible to change this?

container_registry = {
      name        = substr(join("", compact([local.prefix_safe, "cr", local.suffix_safe])), 0, 63)
      name_unique = substr(join("", compact([local.prefix_safe, "cr", local.suffix_unique_safe])), 0, 63)
      dashes      = false
      slug        = "cr" => "acr"
      min_length  = 1
      max_length  = 63
      scope       = "resourceGroup"
      regex       = "^[a-zA-Z0-9]+$"
    }

Example Articles:

#23

Is this project still active?

@Nepomuceno Is this project still active? There are a handful of PRs that have not be addressed in months. Some since last year.

I know there is the azurecaf provider which provides similar functionality. Has this module-based approach been deprecated in favor of the provider? I see you've committed to both so some guidance would be approciated.

Deleting a naming block from a composite module causes "Provider configuration not present" errors.

Should be fixed in #30

You can repro the issue in current code by simply adding something like this to any parent module:

module "bug_naming" {
  source = "Azure/naming/azurerm"
  suffix = [lower(var.datacenter), "dvo", lower(var.environment), lower(var.component)]
}

# This one doesn't matter, just use the bug_naming for something.
module "create_fancy_resource_group" {
  source = "../../submodules/fancy-resource-group"

  resource_group_name = module.bug_naming.resource_group.name
}

# add some third resource so you have something left over after the first two are removed.

terragrunt/terraform apply, and then comment out those two resources and try to apply again. You will get

Error: Provider configuration not present

To work with module.bug_naming.random_string.main its original provider
configuration at
module.bug_naming.provider["registry.terraform.io/hashicorp/random"] is
required, but it has been removed. 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.