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_api_management: fix panic when given empty hostname_configuration #11426

Merged
merged 2 commits into from
Apr 22, 2021

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Apr 22, 2021

Fixes #11422

The panic happens with following configuration:

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "test" {
  name = "apimgmtcrash"
  location = "eastus2"
}

resource "azurerm_api_management" "apimtest" {
  name                = "apimgmtcrash"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name
  publisher_name      = "Terraform"
  publisher_email     = "foo@bar.com"
  sku_name            = "Developer_1"
  identity {
    type = "SystemAssigned"
  }
  hostname_configuration {} # THIS LINE CAUSES PANIC
}

Note that this PR only avoids the panic, whilst it will cause diff in next plan:

  ~ resource "azurerm_api_management" "apimtest" {
        id                        = "/subscriptions/xxx/resourceGroups/apimgmtcrash/providers/Microsoft.ApiManagement/service/apimgmtcrash"
        name                      = "apimgmtcrash"
        tags                      = {}
        # (16 unchanged attributes hidden)

      + hostname_configuration {
        }

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - although the diff is expected here, since this should be omitted if these are managed via the separate resource?

@magodo
Copy link
Collaborator Author

magodo commented Apr 22, 2021

Yes, the diff is expected even there is no azurerm_api_management_custom_domain provisioned. This is because all the nested properties inside the hostname_configuration are Optional.

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - confirmed this has been tested with this configuration too 👍

@katbyte katbyte added this to the v2.57.0 milestone Apr 22, 2021
@katbyte katbyte merged commit eab378c into hashicorp:master Apr 22, 2021
katbyte added a commit that referenced this pull request Apr 22, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.57.0"
}
# ... other configuration ...

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: The terraform-provider-azurerm_v2.45.0_x5.exe plugin crashed!
3 participants