Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_storage_account error deserializing json #3028

Closed
laurencee opened this issue Mar 10, 2019 · 11 comments
Closed

azurerm_storage_account error deserializing json #3028

laurencee opened this issue Mar 10, 2019 · 11 comments

Comments

@laurencee
Copy link

laurencee commented Mar 10, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.11.11

  • provider.azurerm v1.23.0

Affected Resource(s)

  • azurerm_storage_container

Terraform Configuration Files

resource "azurerm_resource_group" "default" {
  name     = "myrg"
  location = "westus2"
}

resource "azurerm_storage_account" "default" {
  name                     = "accountname"
  resource_group_name      = "${azurerm_resource_group.default.name}"
  location                 = "westus2"
  account_tier             = "Standard"
  account_kind             = "StorageV2"
  account_replication_type = "LRS"
}

resource "azurerm_storage_container" "default" {
  name                  = "containername"
  resource_group_name   = "${azurerm_resource_group.default.name}"
  storage_account_name  = "${azurerm_storage_account.default.name}"
  container_access_type = "private"
}

Expected Behavior

terraform command succeeds

Actual Behavior

azurerm_storage_container.default: Error loading the Resource Groups for Storage Account "accountname": storage.AccountsClient#List: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal string into Go struct field CustomDomain.useSubDomainName of type bool'

Steps to Reproduce

  1. terraform apply or terraform plan or terraform import
@darkedges
Copy link

In my case I found that a storage account had

"useSubDomainName": "false" 

instead of

"useSubDomainName": false

Not sure how it was being set.

@kevinneufeld
Copy link

kevinneufeld commented Mar 18, 2019

I am running into the same issue.

azurerm_storage_container.default_web_logs: Error loading the Resource Groups for Storage
Account "f2bbe251059200cc5f95edd": storage.AccountsClient#List: Failure responding 
to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - 
Error = 'json: cannot unmarshal string into Go struct field CustomDomain.useSubDomainName of
type bool'

@mikolajzajac
Copy link

getting same issue - rolling back to a previous version did not help either.

@mikolajzajac
Copy link

mikolajzajac commented Mar 21, 2019

found a workaround to this issue, it is related to the AzureRM Provider v2.0: #2807
tldr: pin the provider version, i.e.

provider "azurerm" {
  version = "=1.22.0"
}

@samuel-begin
Copy link

We rolled back to 1.22.1 when we encountered this, but we will need some new features that will be released with 1.24.0

I'm not sure how we can deal with this yet. Suggestions?

@mikolajzajac

This comment has been minimized.

@IvanovOleg
Copy link

IvanovOleg commented Mar 31, 2019

This error appears when you have an azure storage account in your subscription which has the custom domain feature enabled. It doesn't matter if you manage this account using terraform or not. You can disable that feature, run terraform apply and as soon as terraform passes the initial state check enable that feature again.

@samuel-begin
Copy link

So i have opened an issue in the azure-rest-api-specs repo with all the details.
TLDR: The bug in on azure's side. It should be served as a boolean according to their specs

Since I doubt the terraform team wants to account for this, I have made a fork of the provider and will maintain it until the problem is fixed. As of now, the provider is v1.24.0 with only the type changed for string. It is on this branch and you can build using make build-docker following by replacing the resulting binary in your terraform plugins ~/.terraform.d/plugins/

Enjoy!

@tombuildsstuff
Copy link
Contributor

👋

Unfortunately this is an issue in the Azure API where it can return a string or a boolean depending on the last time the resource was modified (which is why the Go SDK fails to parse this sometime).

As @samuel-begin has mentioned due to this unfortunately there's not a whole bunch we can do within Terraform (or the Go SDK) to work around this, since the API needs to be fixed to pick one or the other (since updating it to a bool will break if a string is returned, and vica-versa) - as such for the moment I'd suggest +1-ing this issue: Azure/azure-rest-api-specs#5626

Thanks!

@tombuildsstuff tombuildsstuff added this to the Blocked milestone May 23, 2019
@tombuildsstuff tombuildsstuff added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label May 23, 2019
@tombuildsstuff tombuildsstuff removed the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Jun 7, 2019
@tombuildsstuff
Copy link
Contributor

👋

Looks like the upstream issue's been fixed by no longer returning this field from the API: Azure/azure-sdk-for-go#4473 - as such this should be fixed, so I'm going to close this issue for the moment

Thanks!

@tombuildsstuff tombuildsstuff removed this from the Blocked milestone Jun 7, 2019
@ghost
Copy link

ghost commented Jul 8, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants