tfmigrate icon indicating copy to clipboard operation
tfmigrate copied to clipboard

Bug when you have module that have the same resource names

Open benjamin-rousseau-shift opened this issue 10 months ago • 0 comments

I discovered the hard way while trying to move 2500+ resources that if you have that case :

  1. Let's assume my migrate.hcl file looks like this :
migration "multi_state" "mv_dir1_dir2" {
  from_dir = "dir1"
  to_dir   = "dir2"
  actions = [
    "xmv azurerm_network_security_group.example[\"*\"] azurerm_network_security_group.example[\"$${1}\"]",
  ]
}
  1. Let's assume my state file has the following resources :
azurerm_network_security_group.example["bar"]
azurerm_network_security_group.example["baz"]
module.example.azurerm_network_security_group.example[0]

it will fail with an error that looks like : cannot find azurerm_network_security_group.example[0] in current state

I think this is because it tries to do a match of azurerm_network_security_group.example no matter if it has something else before (like module.something)

I don't think this is intended.

benjamin-rousseau-shift avatar Apr 11 '24 06:04 benjamin-rousseau-shift