aztfmod / terraform-provider-azurecaf

Terraform provider for the Terraform platform engineering for Azure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azurecaf_name support for import

kmataru opened this issue · comments

Is your feature request related to a problem? Please describe.
Working with terraform-azurerm-caf and having to import lots of cloud resources it leaves azurecaf_name
(even with passthrough = true) as a dependency to the actual resources.

Leaving the last ones in recreate state, even if the name is exactly the same.

  # module.solution.module.batch_accounts["batch_account"].azurecaf_name.account will be created
  + resource "azurecaf_name" "account" {
      + clean_input   = true
      + id            = (known after apply)
      + name          = "BA"
      + passthrough   = true
      + random_length = 0
      + resource_type = "azurerm_batch_account"
      + result        = (known after apply)
      + results       = (known after apply)
      + separator     = "-"
      + use_slug      = true
    }

  # module.solution.module.batch_accounts["batch_account"].azurerm_batch_account.account must be replaced
  # (imported from "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RG/providers/Microsoft.Batch/batchAccounts/BA")
  # Warning: this will destroy the imported resource
-/+ resource "azurerm_batch_account" "account" {
      ~ account_endpoint                    = "BA._.batch.azure.com" -> (known after apply)
      ~ id                                  = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RG/providers/Microsoft.Batch/batchAccounts/BA" -> (known after apply)
      ~ name                                = "BA" # forces replacement -> (known after apply) # forces replacement

Describe the solution you'd like
Probably it would defeat the whole purpose to have the ability to run the import command (somehow).
But I am raising this at a discussion level.

(Maybe this would be a topic for terraform-azurerm-caf project;
and instead of resource "azurecaf_name" there should be data "azurecaf_name")
Update: I was rethinking this and data "azurecaf_name" makes sense only when passthrough = true 😊

Describe alternatives you've considered
As silly as it seemed, I tried running the import command:
Error: resource azurecaf_name doesn't support import