diff --git a/cmd/migrate_command_test.go b/cmd/migrate_command_test.go index 93640a76..bee6bcb8 100644 --- a/cmd/migrate_command_test.go +++ b/cmd/migrate_command_test.go @@ -614,13 +614,13 @@ resource "azapi_resource" "test2" { parent_id = azurerm_resource_group.test.id type = "Microsoft.Automation/automationAccounts@2020-01-13-preview" location = azurerm_resource_group.test.location - body = jsonencode({ + body = { properties = { sku = { - name = jsondecode(azapi_resource.test.output).properties.sku.name + name = azapi_resource.test.output.properties.sku.name } } - }) + } } resource "azurerm_automation_account" "test1" { @@ -634,19 +634,19 @@ resource "azapi_update_resource" "test" { resource_id = azurerm_automation_account.test1.id type = "Microsoft.Automation/automationAccounts@2020-01-13-preview" response_export_values = ["properties.sku"] - body = jsonencode({ + body = { tags = { key = var.Label } - }) + } } output "accountName" { - value = jsondecode(azapi_resource.test.output).name + value = azapi_resource.test.output.name } output "patchAccountSKU" { - value = jsondecode(azapi_update_resource.test.output).properties.sku.name + value = azapi_update_resource.test.output.properties.sku.name } `, template(), randomResourceName(), randomResourceName()) } diff --git a/tf/terraform.go b/tf/terraform.go index 356bd8f2..7ad1841f 100644 --- a/tf/terraform.go +++ b/tf/terraform.go @@ -137,8 +137,8 @@ func (t *Terraform) ListGenericResources(p *tfjson.Plan) []types.GenericResource for j, instance := range resource.Instances { resources[i].Instances[j].Outputs = getOutputsForAddress(resource.OldAddress(instance.Index), refValueMap) for _, output := range resources[i].Instances[j].Outputs { - prop := strings.TrimPrefix(output.OldName, fmt.Sprintf("jsondecode(%s.output).", resource.OldAddress(instance.Index))) - prop = strings.TrimPrefix(prop, fmt.Sprintf("%s.output.", resource.OldAddress(instance.Index))) + prop := strings.TrimPrefix(output.OldName, fmt.Sprintf("%s.output.", resource.OldAddress(instance.Index))) + prop = strings.TrimPrefix(prop, fmt.Sprintf("jsondecode(%s.output).", resource.OldAddress(instance.Index))) if strings.HasPrefix(prop, "identity.userAssignedIdentities") { prop = "identity.userAssignedIdentities" } diff --git a/tf/utils.go b/tf/utils.go index 13eeb82d..021a36e0 100644 --- a/tf/utils.go +++ b/tf/utils.go @@ -33,13 +33,13 @@ func getId(value interface{}) string { func getOutputsForAddress(address string, refValueMap map[string]interface{}) []types.Output { res := make([]types.Output, 0) for key, value := range refValueMap { - if strings.HasPrefix(key, fmt.Sprintf("jsondecode(%s.output)", address)) { + if strings.HasPrefix(key, fmt.Sprintf("jsondecode(%s.output).", address)) { res = append(res, types.Output{ OldName: key, Value: value, }) } - if strings.HasPrefix(key, fmt.Sprintf("%s.output", address)) { + if strings.HasPrefix(key, fmt.Sprintf("%s.output.", address)) { res = append(res, types.Output{ OldName: key, Value: value,