{"id":26718644,"url":"https://github.com/aristosvo/aztfmove","last_synced_at":"2025-04-14T03:35:53.224Z","repository":{"id":37928569,"uuid":"368678199","full_name":"aristosvo/aztfmove","owner":"aristosvo","description":"Simple tool to move Azure resources based on Terraform state","archived":false,"fork":false,"pushed_at":"2024-10-02T12:04:33.000Z","size":478,"stargazers_count":41,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T16:15:12.600Z","etag":null,"topics":["azure","move","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aristosvo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-18T22:09:08.000Z","updated_at":"2025-03-14T11:03:39.000Z","dependencies_parsed_at":"2024-08-09T14:01:27.187Z","dependency_job_id":null,"html_url":"https://github.com/aristosvo/aztfmove","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aristosvo%2Faztfmove","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aristosvo%2Faztfmove/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aristosvo%2Faztfmove/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aristosvo%2Faztfmove/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aristosvo","download_url":"https://codeload.github.com/aristosvo/aztfmove/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248817542,"owners_count":21166261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","move","terraform"],"created_at":"2025-03-27T17:35:39.798Z","updated_at":"2025-04-14T03:35:53.198Z","avatar_url":"https://github.com/aristosvo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aztfmove\nSimple tool to move Azure resources based on Terraform state\n\n## Goal\nIt is sometimes inevitable to move Azure resources to a new subscription or to a different resource group within an Azure Tenant. This means often a painfull transition when all resources are already in Terraform.\n\nTo combine both the joy of Terraform and the movement capabilities within Azure, this tool gives you the capabilities to migrate quick and easy.\n\n## Usage\n```\n❯ aztfmove -h\nUsage of aztfmove:\n  -auto-approve\n        aztfmove first shows which resources are selected for a move and requires approval. If you want to approve automatically, use this flag.\n  -dry-run\n        if set to true, aztfmove only shows which resources are selected for a move.\n  -module string\n        Terraform module to be moved. For example \"module.storage\". (default \"*\")\n  -resource string\n        Terraform resource to be moved. For example \"module.storage.azurerm_storage_account.example\". (default \"*\")\n  -resource-group string\n        Azure resource group to be moved. For example \"example-source-resource-group\". (default \"*\")\n  -subscription-id string\n        subscription where resources are currently. Environment variable \"ARM_SUBSCRIPTION_ID\" has the same functionality. (default \"3xampl32-uu1d-11eb-8529-0242ac130003\")\n  -target-resource-group string\n        Azure resource group name where resources are moved. For example \"example-target-resource-group\". (required)\n  -target-subscription-id string\n        Azure subscription ID where resources are moved. If not specified resources are moved within the subscription. (default \"3xampl32-uu1d-11eb-8529-0242ac130003\")\n  -var value\n        use this like you'd use Terraform \"-var\", i.e. \"-var 'test1=123' -var 'test2=312'\" \n  -var-file value\n        use this like you'd use Terraform \"-var-file\", i.e. \"-var-file=tst.tfvars\"\n```\n\n## Setup\n\nRun:\n```bash\ngo install github.com/aristosvo/aztfmove\n```\n\n## Authentication\n\nAuthentication for Terraform is the same for `aztfmove` as for normal `terraform` operations. Start with `terraform init` to make sure the (remote) terraform state is available.\n\nAuthentication for the movements in Azure is based on an default [azure-sdk-for-go](https://github.com/Azure/azure-sdk-for-go) authorizer which uses Azure CLI to obtain its credentials.\n\nTo use this way of authentication, follow these steps:\n\n1. Install Azure CLI v2.0.12 or later. Upgrade earlier versions.\n2. Use az login to sign in to Azure.\n\nIf you receive an error, use `az account get-access-token` to verify access.\n\nIf Azure CLI is not installed to the default directory, you may receive an error reporting that az cannot be found.\nUse the AzureCLIPath environment variable to define the Azure CLI installation folder.\n\nIf you are signed in to Azure CLI using multiple accounts or your account has access to multiple subscriptions, you need to specify the specific subscription to be used. To do so, use:\n\n```\naz account set --subscription \u003csubscription-id\u003e\n```\nTo verify the current account settings, use:\n```\naz account list\n```\n\n## Examples\nFor examples and/or tests, see [test](https://github.com/aristosvo/aztfmove/tree/main/test) directory.\n\nSample output for part of the `basic-storage` test run below:\n```\n❯ aztfmove -target-resource-group input-sa-rg\nNo unique \"-target-subscription-id\" specified, move will be within the same subscription:\n 3xampl32-uu1d-11eb-8529-0242ac130003 -\u003e 3xampl32-uu1d-11eb-8529-0242ac130003\n\nResources not supported for movement:\n - azurerm_resource_group.input-rg\n - azurerm_resource_group.output-rg\n\nResources to be moved in Azure:\n - /subscriptions/3xampl32-uu1d-11eb-8529-0242ac130003/resourceGroups/output-sa-rg/providers/Microsoft.Storage/storageAccounts/samove9ywva4a1\n\nResources to be corrected in Terraform:\n - azurerm_storage_account.sa-move\n - azurerm_storage_container.sc-move\n\nCan you confirm these resources should be moved?\nCheck the Azure documentation to move Azure resources (https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/move-resource-group-and-subscription) for all the details on your specific resources.\n\nType 'yes' to confirm: yes\n\nResources are on the move to the specified resource group.\nIt can take some time before this is done, don't panic!\n\nResources are moved to the specified resource group.\n\nResources in Terraform state are enhanced:\n - azurerm_storage_account.sa-move\n    ✓ Removed   ✓ Imported\n - azurerm_storage_container.sc-move\n    ✓ Removed   ✓ Imported\n\nCongratulations! Resources are moved in Azure and corrected in Terraform.\n```\n\n\n## ToDo\n- [ ] Use [terraform-exec](https://github.com/hashicorp/terraform-exec) instead of wrapping `terraform`\n- [ ] Multiple authentication options (ideally all options supported in the provider)\n\n## Licence\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faristosvo%2Faztfmove","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faristosvo%2Faztfmove","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faristosvo%2Faztfmove/lists"}