Azure / aztfexport

A tool to bring existing Azure resources under Terraform's management
https://azure.github.io/aztfexport/
Mozilla Public License 2.0
1.58k stars 182 forks source link

Unmarshalling error using new map feature #278

Closed wylie-ucb closed 1 year ago

wylie-ucb commented 1 year ago

We're trying to use the new map feature so we can import resources using friendly names (so replacing the default 'res-NN' names). During the initialization phase, the error is seen within a couple seconds.

Environment: azurerm version: 3.22.0 go version: go1.18.3 windows/amd64 terraform version: v1.2.2

Command: $env:ARM_ENVIRONMENT = 'usgovernment' aztfy map ..\.aztfyResourceMapping.json

Data: { "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]": "azurerm_resource_group.lz", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/azureFirewalls/[REDACTED]": "azurerm_firewall.lz", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/firewallPolicies/[REDACTED]": "azurerm_firewall_policy.lz", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/firewallPolicies/[REDACTED]/ruleCollectionGroups/DefaultApplicationRuleCollectionGroup": "azurerm_firewall_policy_rule_collection_group.lz_app", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/firewallPolicies/[REDACTED]/ruleCollectionGroups/DefaultDnatRuleCollectionGroup": "azurerm_firewall_policy_rule_collection_group.lz_dnat", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/firewallPolicies/[REDACTED]/ruleCollectionGroups/DefaultNetworkRuleCollectionGroup": "azurerm_firewall_policy_rule_collection_group.lz_net", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/virtualNetworks/[REDACTED]/subnets/[REDACTED]": "azurerm_subnet.lz_fw", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/publicIPAddresses/[REDACTED]": "azurerm_public_ip.lz_fw", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/virtualNetworks/[REDACTED]": "azurerm_virtual_network.lz", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/ipGroups/[REDACTED]": "azurerm_ip_group.afs", "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Network/ipGroups/[REDACTED]": "azurerm_ip_group.avd" }

Result: unmarshalling the mapping file: json: cannot unmarshal string into Go value of type resmap.ResourceMapEntity

Note that issue #276 is also happening to us, and we are working in Azure US Gov 2022-10-27_19-00-28

magodo commented 1 year ago

@wylie-ucb The mapping file format has been changed in v0.8.0, see: https://github.com/Azure/aztfy/releases/tag/v0.8.0. For the new format, please checkout the readme: https://github.com/Azure/aztfy#terrafy-a-predefined-set-of-resources

wylie-ucb commented 1 year ago

Thanks @magodo . I was using the mapping file from 0.7.0 since 0.8.0 isn't working for us. I'll wait for #276 to be built and try again.

magodo commented 1 year ago

@wylie-ucb Since we haven't get further response from you, I'll mark this issue as closed for now. Feel free to reopen it if the issue still remains.