claranet / terraform-azurerm-rg

Terraform module for Azure Resource Group
Apache License 2.0
10 stars 20 forks source link

[BUG] name_suffix does not work as expected or not documented properly #1

Closed zen closed 1 year ago

zen commented 1 year ago

Community Note

Terraform Version

1.4.6

AzureRM Provider Version

3.61.0

Affected Resource(s)/Data Source(s)

azurerm_resource_group

Terraform Configuration Files

I'm using Terragrunt, but essentially what I do is

locals {
  g_vars = read_terragrunt_config(find_in_parent_folders("global.hcl"))
  e_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
  r_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))

  path_suffix = g_vars.locals.path_suffix

  resource_name_suffix = "001"

  tags = merge(
    local.g_vars.inputs.global_tags,
    local.e_vars.inputs.env_tags,
    local.r_vars.inputs.region_tags,
    {
      # any additional local tags
      tf_path = "${local.path_suffix}/${path_relative_to_include()}"
  })
}
inputs = {
  # use values merged from included configs
  location    = dependency.region.outputs.location
  name        = dependency.region.outputs.name
  name_suffix = local.resource_name_suffix

  extra_tags = merge(
    local.tags
  )
}

Debug Output/Panic Output

Terraform will perform the following actions:

  # azurerm_resource_group.main_rg will be created
  + resource "azurerm_resource_group" "main_rg" {
      + id       = (known after apply)
      + location = "eastus"
      + name     = "rg-infra-xxx-prod"
      + tags     = {
          + "client"     = "xxx"
          + "env"        = "prod"
          + "repository" = "xxx"
          + "stack"      = "infra"
          + "tf_managed" = "true"
          + "tf_path"    = "envs/prod/eastus/rg-001"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + resource_group_id       = (known after apply)
  + resource_group_location = "eastus"
  + resource_group_name     = "rg-infra-xxx-prod"

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.


### Expected Behaviour

Resource name should be `rg-infra-xxx-prod-001`

### Actual Behaviour

REsource is `rg-infra-xxx-prod`

### Steps to Reproduce

_No response_

### Important Factoids

_No response_

### References

_No response_
zen commented 1 year ago

Moreover I noticed that I cannot get custom resource name as well:

inputs = {
  # use values merged from included configs
  location    = dependency.region.outputs.location
  name        = dependency.region.outputs.name
  name_suffix = local.resource_name_suffix

  #use_caf_naming = false

  custom_rg_name = "rg-infra-sensfix-prod-001"

  extra_tags = merge(
    local.tags
  )
}

Still produces the same output. I experimented with setting use_caf_naming = false etc. No change :(

zen commented 1 year ago

Kindly ignore the report it was error on my end ;)