Skip to content
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

Feature request: support cross-providers resource move #664

Closed
ms-henglu opened this issue Nov 8, 2024 · 3 comments
Closed

Feature request: support cross-providers resource move #664

ms-henglu opened this issue Nov 8, 2024 · 3 comments
Milestone

Comments

@ms-henglu
Copy link
Member

Terraform supports moved block which allows moving between two resources of different types. By supporting the new protocol, the resources from azurerm provider could be moved to azapi provider.

Here's an example:

resource "azurerm_resource_group" "test" {
  name     = "acctesthenglu1031"
  location = "East US"
}

# resource "azurerm_data_factory" "test" {
#   name                   = "heng"
#   location               = azurerm_resource_group.test.location
#   resource_group_name    = azurerm_resource_group.test.name
#   public_network_enabled = true
#   identity {
#     type = "SystemAssigned"
#   }
# }

moved {
  from = azurerm_data_factory.test
  to   = azapi_resource.factory
}

resource "azapi_resource" "factory" {
  type      = "Microsoft.DataFactory/factories@2018-06-01"
  parent_id = azurerm_resource_group.test.id
  name      = "heng"
  location  = "eastus"
  identity {
    type         = "SystemAssigned"
    identity_ids = []
  }

  body = {
    properties = {
      globalParameters    = {}
      publicNetworkAccess = "Enabled"
    }
  }
}

@ms-henglu ms-henglu added this to the v2.1.0 milestone Nov 8, 2024
@stemaMSFT
Copy link
Member

@ms-henglu does the end result behavior differ much from a removed and import block? Curious to see how this behaviors works across layers of modules as well.

@ms-henglu
Copy link
Member Author

@stemaMSFT - Yes, there're some differences:

  1. The major difference is the moved block could be used inside a module(it could also work across layers of modules), so for the module users, the migration could be transparent and without breaking changes.
  2. The plan output is different:
    1. The removed + import output: One resource will be imported and one resource will be no longer managed by Terraform.
    2. The moved output: The azurerm resource has been moved to azapi resource.

@ms-henglu
Copy link
Member Author

Completed via #668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants