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_operation - will no longer panic on missing values in request #5318

Merged
merged 1 commit into from Jan 8, 2020

Conversation

jackbatzner
Copy link
Contributor

Actually fix the panic correctly this time as referenced in PR 5273

The following configuration was providing the following plan:

variable "query_parameters" {
  type = list(object({
    name        = string
    type        = string
    description = string
    required    = bool
  }))
  default     = []
  description = "The query parameters definition"
}

resource "azurerm_api_management_api_operation" "test-operation2" {
  operation_id        = "testoperation"
  api_name            = "testEndpoint"
  api_management_name = "${module.api_management.api_management_name}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"

  display_name = "testOperation2"
  method       = "GET"
  url_template = "/cause/a/crash"
  description  = "An endpoint that will find a bug"

  request {
    dynamic "query_parameter" {
      for_each = var.query_parameters

      content {
        name        = query_parameter.value.name
        type        = query_parameter.value.type
        required    = query_parameter.value.required
        description = query_parameter.value.description
        default_value = ""
        values        = []
      }
    }
  }

  dynamic "template_parameter" {
    for_each = var.url_template_parameters

    content {
      name          = template_parameter.value.name
      type          = template_parameter.value.type
      required      = template_parameter.value.required
      description   = template_parameter.value.description
      default_value = ""
      values        = []
    }
  }
}
   + resource "azurerm_api_management_api_operation" "test-operation2" {
       + api_management_name = "testapim"
       + api_name            = "test"
       + description         = "An endpoint that will find a bug"
       + display_name        = "testOperation2"
       + id                  = (known after apply)
       + method              = "GET"
       + operation_id        = "testoperation"
       + resource_group_name = "jack-test-rg"
       + url_template        = "/cause/a/crash"

       + request {
         }
     }

With the important thing being the empty request object. The error handling I added previously did not actually fix this correctly. I confirmed by compiling the provider locally and using the compiled provider.

@jackbatzner
Copy link
Contributor Author

The one question I do have though is, am I doing the dynamic block correctly? Ideally there would be no request block if there are no query_parameter.

resource "azurerm_api_management_api_operation" "test-operation2" {
  ...

  request {
    dynamic "query_parameter" {
      for_each = var.query_parameters

      content {
        name        = query_parameter.value.name
        type        = query_parameter.value.type
        required    = query_parameter.value.required
        description = query_parameter.value.description
        default_value = ""
        values        = []
      }
    }
  }
...
}

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @Brunhil, that additional check is definitely required 👍

@katbyte katbyte merged commit b17fc98 into hashicorp:master Jan 8, 2020
katbyte added a commit that referenced this pull request Jan 8, 2020
@ghost
Copy link

ghost commented Jan 16, 2020

This has been released in version 1.41.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 = "~> 1.41.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Feb 8, 2020

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!

@hashicorp hashicorp locked and limited conversation to collaborators Feb 8, 2020
@jackbatzner jackbatzner deleted the apim_op_panic branch March 14, 2020 14:48
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.

None yet

3 participants