Azure / terraform-azurerm-lz-vending

Terraform module to deploy landing zone subscriptions (and much more) in Azure
https://registry.terraform.io/modules/Azure/lz-vending/azurerm
MIT License
171 stars 82 forks source link

bug: Error cannot unmarshal string into Go #425

Closed samuelchong closed 1 month ago

samuelchong commented 1 month ago

Community Note

Please paste the output of terraform version command from within the initialized directory:

$ terraform version
Terraform v1.9.8
on windows_amd64
+ provider registry.terraform.io/azure/azapi v2.0.1
+ provider registry.terraform.io/hashicorp/azuread v2.47.0
+ provider registry.terraform.io/hashicorp/azurerm v3.94.0
+ provider registry.terraform.io/hashicorp/random v3.6.3
+ provider registry.terraform.io/hashicorp/time v0.12.1

Please enter the module version that you are using:

4.1.4

Description

# output from terraform apply
β”‚ Error: Invalid body
β”‚ 
β”‚   with module.landingzone.azapi_resource.telemetry_root,
β”‚   on .terraform\modules\landingzone\main.telemetry.tf line 3, in resource "azapi_resource" "telemetry_root":
β”‚    3: resource "azapi_resource" "telemetry_root" {
β”‚
β”‚ The argument "body" is invalid: unmarshaling failed: value:
β”‚ "{\"properties\":{\"mode\":\"Incremental\",\"template\":{\"$schema\":\"https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#\",\"contentVersion\":\"1.0.0.0\",\"outputs\":{\"telemetry\":{\"type\":\"String\",\"value\":\"For
β”‚ more information, see https://aka.ms/lz-vending/tf/telemetry\"}},\"parameters\":{},\"resources\":[],\"variables\":{}}}}", err: json: cannot unmarshal string into Go 
β”‚ value of type map[string]interface {}
β•΅
β•·
β”‚ Error: Invalid Type
β”‚
β”‚   with module.landingzone.azapi_resource.telemetry_root,
β”‚   on .terraform\modules\landingzone\main.telemetry.tf line 9, in resource "azapi_resource" "telemetry_root":
β”‚    9:   body = jsonencode({
β”‚   10:     properties = {
β”‚   11:       mode     = "Incremental"
β”‚   12:       template = local.telem_arm_subscription_template
β”‚   13:     }
β”‚   14:   })
β”‚
β”‚ The value must not be a string
β•΅
β•·
β”‚ Error: Invalid body
β”‚
β”‚   with module.landingzone.module.resourcegroup.azapi_resource.rg,
β”‚   on .terraform\modules\landingzone\modules\resourcegroup\main.tf line 1, in resource "azapi_resource" "rg":
β”‚    1: resource "azapi_resource" "rg" {
β”‚
β”‚ The argument "body" is invalid: unmarshaling failed: value: "{}", err: json: cannot unmarshal string into Go value of type map[string]interface {}
β•΅
β•·
β”‚ Error: Invalid body
β”‚
β”‚   with module.landingzone.module.resourcegroup_networkwatcherrg.azapi_resource.rg,
β”‚   on .terraform\modules\landingzone\modules\resourcegroup\main.tf line 1, in resource "azapi_resource" "rg":
β”‚    1: resource "azapi_resource" "rg" {
β”‚
β”‚ The argument "body" is invalid: unmarshaling failed: value: "{}", err: json: cannot unmarshal string into Go value of type map[string]interface {}
β•΅
β•·
β”‚ Error: Invalid Type
β”‚
β”‚   with module.landingzone.module.resourcegroup.azapi_resource.rg,
β”‚   on .terraform\modules\landingzone\modules\resourcegroup\main.tf line 6, in resource "azapi_resource" "rg":
β”‚    6:   body      = jsonencode({})
β”‚
β”‚ The value must not be a string
β•΅
β•·
β”‚ Error: Invalid Type
β”‚
β”‚   with module.landingzone.module.resourcegroup_networkwatcherrg.azapi_resource.rg,
β”‚   on .terraform\modules\landingzone\modules\resourcegroup\main.tf line 6, in resource "azapi_resource" "rg":
β”‚    6:   body      = jsonencode({})
β”‚
β”‚ The value must not be a string
β•΅
β•·
β”‚ Error: Invalid body
β”‚
β”‚   with module.landingzone.module.usermanagedidentity.azapi_resource.umi,
β”‚   on .terraform\modules\landingzone\modules\usermanagedidentity\main.tf line 32, in resource "azapi_resource" "umi":
β”‚   32: resource "azapi_resource" "umi" {
β”‚
β”‚ The argument "body" is invalid: unmarshaling failed: value: "{}", err: json: cannot unmarshal string into Go value of type map[string]interface {}
β•΅
β•·
β”‚ Error: Invalid Type
β”‚
β”‚   with module.landingzone.module.usermanagedidentity.azapi_resource.umi,
β”‚   on .terraform\modules\landingzone\modules\usermanagedidentity\main.tf line 36, in resource "azapi_resource" "umi":
β”‚   36:   body      = jsonencode({})
β”‚
β”‚ The value must not be a string
β•΅

Steps to Reproduce

  1. terraforn init
  2. terraform plan

Screenshots

Additional context

source = "Azure/lz-vending/azurerm" It was working fine one on module 4.1.2 up until approx a week ago.

Start getting this error today.

samuelchong commented 1 month ago

Tried disable_telemetry, still getting error

"landingzone" { source = "Azure/lz-vending/azurerm" version = "4.1.4"

version = "4.0.1"

disable_telemetry = true

.......

sample variable files:

resource_groups = {
  "cicd" = {
    name     = "cicd"
    location = "australiaeast"
    tags     = { Workload = "abc" }
  },
  "sfa-base-rg" = {
    name     = "tss-xxx-base-ci-aue-rg"
    location = "australiaeast"
    tags     = { Workload = "abc" }
  },
samuelchong commented 1 month ago

looks like an issue with jsonencode({})

mrWiecekWil commented 1 month ago

Is there currently workaround for this problem ?

samuelchong commented 1 month ago

I haven't found any workaround.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: mrWiecekWil @.> Sent: Tuesday, October 22, 2024 6:21:55 pm To: Azure/terraform-azurerm-lz-vending @.> Cc: Samuel Chong @.>; Author @.> Subject: Re: [Azure/terraform-azurerm-lz-vending] bug: Error cannot unmarshal string into Go (Issue #425)

Is there currently workaround for this problem ?

β€” Reply to this email directly, view it on GitHubhttps://github.com/Azure/terraform-azurerm-lz-vending/issues/425#issuecomment-2428456867, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABDHOJ6M47FJ5HUE3SSRBXTZ4X4JHAVCNFSM6AAAAABQLLYYWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRYGQ2TMOBWG4. You are receiving this because you authored the thread.Message ID: @.***>

matt-FFFFFF commented 1 month ago

As a workaround please cap your AzAPI provider version to ~> 1.15

We will work on supporting AzAPI v2 in the coming weeks

matt-FFFFFF commented 1 month ago

Closing as dupe of #406