aztfmod / terraform-provider-azurecaf

Terraform provider for the Terraform platform engineering for Azure
MIT License
174 stars 93 forks source link

The resource 'azurecaf_name' is generating error for the 'azurerm_shared_image_gallery' type. #54

Closed benhurjoel closed 3 years ago

benhurjoel commented 3 years ago

I'm trying to generate a name for a Shared Image Gallery using azurecaf_name. My code as follows:

resource "azurecaf_name" "sig_name" {
  for_each =  local.shared_services.shared_image_gallery.galleries
  name          = each.value.name
  prefixes      = [local.global_settings.prefix]
  resource_type = "azurerm_shared_image_gallery"
  random_length = local.global_settings.random_length
  clean_input   = true
  passthrough   = local.global_settings.passthrough
}

I'm getting the following error:

Error: Invalid name for CAF naming azurerm_shared_image_gallery test1, the pattern ^[a-zA-Z0-9][a-zA-Z0-9.]{0,78}[a-zA-Z0-9]$ doesn't match

screen-cap:

image

Please advise.

benhurjoel commented 3 years ago

Shared Image Gallery name limitations:

image

Nepomuceno commented 3 years ago

On Mon, 19 Oct 2020 at 07:43, Ben notifications@github.com wrote:

Shared Image Gallery name limitations:

  • The value must be between 1 and 80 characters long
  • cannot contain special characters /""[]:|<>+=;,?*@& or begin with '_' or end with '.' or '-'.
  • cannot contain hyphen (-) but can have underscore.

[image: image] https://user-images.githubusercontent.com/57881441/96410094-f1317f00-1218-11eb-994a-bbe8b6323d44.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aztfmod/terraform-provider-azurecaf/issues/54#issuecomment-711675845, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2AFOCQVUYOSNRGYVX3Y3SLPNYTANCNFSM4SVVYXTQ .

You put only variables for the parameters can I get one example of what the parameters do look like so I can reproduce the error. Give me one of the each cases and some example prefixes and suffixes.

benhurjoel commented 3 years ago

The values I supply for the Shared Image Gallery goes like this:

shared_image_gallery = {

  galleries = {
    gallery1 ={
      name = "test1"
      resource_group_key = "sig"
      description = " "
    }
    gallery2 = {
      name = "test2"
      resource_group_key = "sig2"
      description = " "
    }
  }

Prefixes are derived from Launchpad global settings.

benhurjoel commented 3 years ago

Thank you @arnaudlh and @Nepomuceno . #69 fixed it.

arnaudlh commented 3 years ago

Closing as fixed in #69