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_automation_dsc_configuration is broken since provider version 2.96.0 #16103

Closed
dz-sourced opened this issue Mar 28, 2022 · 6 comments
Closed

Comments

@dz-sourced
Copy link

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.14.7
+ provider registry.terraform.io/hashicorp/azurerm v3.0.2

Affected Resource(s)

  • azurerm_automation_dsc_configuration

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.0.2"
    }
  }
}

# Configure the Microsoft Azure Provider
provider "azurerm" {
  features {}
}


resource "azurerm_resource_group" "example" {
  name     = "azurerm_issue_example"
  location = "Canada Central"
}

resource "azurerm_automation_account" "example" {
  name                = "account1"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  sku_name = "Basic"

}

resource "azurerm_automation_dsc_configuration" "example" {
  name                    = "test"
  resource_group_name     = azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name
  location                = azurerm_resource_group.example.location
  content_embedded        = "configuration test {}"
}

Expected Behaviour

A new DSC configuration should be successfully created.

Actual Behaviour

Trying to apply the above code snippet produces the following error, starting with version 2.96.0 of the azurerm provider:

2022/03/28 11:29:45 [DEBUG] azurerm_automation_dsc_configuration.example: apply errored, but we're indicating that via
 the Error pointer rather than returning it: making Read request on AzureRM Automation Dsc Configuration content "test
": automation.DscConfigurationClient#GetContent: Failure responding to request: StatusCode=200 -- Original Error: Erro
r occurred unmarshalling JSON - Error = 'invalid character 'c' looking for beginning of value' JSON = 'configuration t
est {}'

Steps to Reproduce

Run apply on the code snippet above:

  1. terraform apply

References

I've done some preliminary debugging and I think the issue can be tracked down to the Azure SDK version change in provider v2.96.0:

"github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2020-01-13-preview/automation"

In the 2020-01-13-preview/automation the actual failure seems to happen when trying to unmarshall DSC Configuration content from JSON:
https://github.com/Azure/azure-sdk-for-go/blob/94316bad34922dee81518b17ddb1454d7a5f89c8/services/preview/automation/mgmt/2020-01-13-preview/automation/dscconfiguration.go#L384

Since the azurerm_automation_dsc_configuration.content_embedded is not a valid JSON we get an error. This was not happening in the previous version of the API 2018-06-30-preview/automation and the content value was just passed as is:
https://github.com/Azure/azure-sdk-for-go/blob/94316bad34922dee81518b17ddb1454d7a5f89c8/services/preview/automation/mgmt/2018-06-30-preview/automation/dscconfiguration.go#L383

Finally, the root cause can be traced to the change in the Swagger API definitions. The latest version of the GetContent API defines the output as a string type, which I assume is tried to be de-serialized from JSON by default:
https://github.com/Azure/azure-rest-api-specs/blob/3034ada77d465b317cda51250a92454824cca06b/specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/dscConfiguration.json#L309

In the earlier version of the API spec the output type is set to file:
https://github.com/Azure/azure-rest-api-specs/blob/3026119ab41bbce77275cfa3a1afbabf43af5aea/specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/dscConfiguration.json#L309

I don't know whether this was intentional API spec change, or whether there is a need to provide further type modifiers in the Swagger API or whether it's an issue with the SDK codegen tool.

Happy to open issues in SDK and API specs repo if someone could validate my assumptions about the root cause of the issue.

@dz-sourced
Copy link
Author

I have also opened an issue with Azure SDK for Go — Azure/azure-sdk-for-go#17591

@prubis
Copy link

prubis commented Apr 29, 2022

Probably another duplicate of #10858

@tombuildsstuff FYI

@nl2rma

This comment was marked as off-topic.

@rezarms

This comment was marked as off-topic.

@tombuildsstuff
Copy link
Contributor

Fixed via #22403

@tombuildsstuff tombuildsstuff added this to the v3.65.0 milestone Jul 7, 2023
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2024
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

7 participants