-
Notifications
You must be signed in to change notification settings - Fork 116
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
how to use this module with multiple resources? #150
Comments
It can't generate random characters each time you reference the name_unique property as it's not a method. The unique value has been generated once and then assembled with each resource type available in the format Azure expects for that resource. Wrap your resource group in a module with the naming module and then you can call it as many times as you want. |
I have the same issue. I built a helper module around this to provide a set of naming conventions depending on the way the resource is being used. My preferred naming convention is to append a random ID that is specific to each instance of each resource. This allows for
...you get the point. The AWS provider gets around this by providing a I realize this isn't really a problem specific to this module, but if there were a solution, I would love to see it reflected here. Has anyone thought of something that overcomes this? |
Similar issue #71 |
I started using this module recently, but I am struggling to understand how it handles random instance numbers when dealing with multiple resources of the same type.
I have the following code, and all I want to do is to have 2 resource groups, with a random instance number at the end (as a suffix).
module "websiteNaming" {
source = "Azure/naming/azurerm"
suffix = [ "n", "web", "dev" ]
prefix = [ "xyz" ]
unique-length = 2
unique-include-numbers = true
}
resource "azurerm_resource_group" "xyz_website" {
name = module.websiteNaming.resource_group.name_unique
location = "West US"
}
resource "azurerm_resource_group" "dof_website2" {
name = module.websiteNaming.resource_group.name_unique
location = "West US"
}
but what I end up with, is 2 resource groups with the same name.
resource "azurerm_resource_group" "xyz_website" {
id = "/subscriptions/xxx-xxxx-xxx/resourceGroups/xyz-rg-n-web-dev-xe"
location = "West US"
managed_by = null
name = "xyz-rg-n-web-dev-xe"
}
resource "azurerm_resource_group" "xyz_website2" {
id = "/subscriptions/xxx-xxxx-xxx/resourceGroups/xyz-rg-n-web-dev-xe"
location = "West US"
managed_by = null
name = "xyz-rg-n-web-dev-xe"
}
All I want to have is something like xyz-rg-n-web-dev-87 and xyz-rg-n-web-dev-76 where the instance numbers are randomly generated.
How can I do this with this module? it sounds strange to have a different naming module for each same type resource - what if I wanted to create a 100 web apps with this module, where the names of the web apps are unique (unique instance number)?
Please help me.
thanks.
The text was updated successfully, but these errors were encountered: