Azure / aztfexport

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

Issue: Error occurred unmarshalling JSON #307

Closed farreciado closed 1 year ago

farreciado commented 1 year ago

Hello, I have no error, but no results! Using version 0.9. After executing a basic

aztfy rg RESOURCE_GROUP_NAME

The process goes normally, a list of resources is generated, and I choose import. It takes some minutes and the progress bar goes up to 100%, then goes back to the resources list. After exit, no error is shown, but no state files are saved!

I quickly created a new RG from scratch and the command goes fine in same azure subscription, creating the tfstate file.

How can I get details of Aztfy execution on that RG? Thanks!

magodo commented 1 year ago

@farreciado In that case, it indicates there are resources have import errors. You can navigate through the resource list view and search for items that is prefixed by an error emoji and press e to see the details. Alternatively, you can run it in --non-interactive mode, in which case it will error out if hit any error (unless you specifiy the --continue option to continue on error).

It takes some minutes

Performance is improved a lot if v0.9.0, you can give it a try.

farreciado commented 1 year ago

Great @magodo , running in non-interactive mode gave some light. I copy here the error in case it helps you improve the tool. In this case is a JSON issue: Error occurred unmarshalling JSON

Error: Failed to import /subscriptions/FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF/resourceGroups/MYRESOURCEGROUP/providers/Microsoft.Web/connections/smtp as azurerm_api_connection.res-507: exit status 1

Error: retrieving Connection (Subscription: "FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF" Resource Group Name: "MYRESOURCEGROUP" Connection Name: "smtp"): connections.ConnectionsClient#Get: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal number into Go struct field ApiConnectionDefinitionProperties.properties.nonSecretParameterValues of type string' JSON = '{"kind":"V1","properties":{"displayName":"SMTP O365 ","authenticatedUser":{},"overallStatus":"Connected","statuses":[{"status":"Connected"}],"connectionState":"Enabled","customParameterValues":{},"nonSecretParameterValues":{"serverAddress":"smtp.office365.com","userName":"mail@office.com","port":587,"enableSSL":true},"createdTime":"2020-10-06T07:15:15.5404427Z","changedTime":"2020-10-06T07:15:15.5404427Z","api":{"name":"smtp","displayName":"SMTP","description":"SMTP (Simple Mail Transfer Protocol) is an internet standard for email supported by most email processing servers. Connect to SMTP to send email.","iconUri":"https://connectoricons-prod.azureedge.net/releases/v1.0.1602/1.0.1602.3056/smtp/icon.png","brandColor":"#e75300","category":"Standard","id":"/subscriptions/FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF/providers/Microsoft.Web/locations/westeurope/managedApis/smtp","type":"Microsoft.Web/locations/managedApis"},"testLinks":[{"requestUri":"https://management.azure.com:443/subscriptions/FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF/resourceGroups/MYRESOURCEGROUP/providers/Microsoft.Web/connections/smtp/extensions/proxy/TestConnection?api-version=2016-06-01","method":"get"}],"testRequests":[{"body":{"request":{"method":"get","path":"TestConnection"}},"requestUri":"https://management.azure.com:443/subscriptions/FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF/resourceGroups/MYRESOURCEGROUP/providers/Microsoft.Web/connections/smtp/dynamicInvoke?api-version=2016-06-01","method":"POST"}]},"id":"/subscriptions/FFFF8db-81b9-FFFF-FFFF-d7d40f4dFFFF/resourceGroups/MYRESOURCEGROUP/providers/Microsoft.Web/connections/smtp","name":"smtp","type":"Microsoft.Web/connections","location":"westeurope"}'

Regarding performance in 0.9 yes, it's trully faster, in this case took a while as the rg has hundreds of items.

magodo commented 1 year ago

@farreciado This appears to be an issue in azurerm provider, could you please confirm the issue remains even via a plain terraform import and submit an issue at here?

magodo commented 1 year ago

@farreciado 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.