hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.58k stars 4.62k forks source link

Validation broken on azurerm_api_management_named_value.display_name #24856

Closed antgustech closed 8 months ago

antgustech commented 8 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.7.3

AzureRM Provider Version

3.91.0

Affected Resource(s)/Data Source(s)

3.91.0

Terraform Configuration Files

resource "azurerm_api_management_named_value" "my_hostname" {
  display_name        = "my_hostname"
}

Debug Output/Panic Output

│ Error: "display_name" may only contain alphanumeric characters, periods, underscores and dashes

Expected Behaviour

Would expect underscores to work.

Actual Behaviour

Error during plan

Steps to Reproduce

No response

Important Factoids

Reverting to azurerm version 3.87.0 seems to resolve the issue.

References

No response

kWozniak-tt commented 8 months ago

We have the same issue after moving from hashicorp/azurerm v3.90.0 So there is regression between hashicorp/azurerm v3.90.0->v3.91.0

clarkminor commented 8 months ago

Also hitting this. Here are the debug logs:

2024-02-12T14:42:05.799-0600 [DEBUG] provider.terraform-provider-azurerm_v3.91.0_x5: AzureRM Request: 
    GET /subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.ApiManagement/service/APIM_SERVICE/namedValues/backend-eastus2-1?api-version=2022-08-01 HTTP/1.1
    Host: management.azure.com
    User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 namedvalue/2022-08-01) HashiCorp Terraform/1.5.2 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/3.91.0 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
    Content-Type: application/json; charset=utf-8
    X-Ms-Correlation-Request-Id: 8f5d5c33-1da7-805c-f91c-3983a618e726
    Accept-Encoding: gzip: timestamp=2024-02-12T14:42:05.799-0600

2024-02-12T14:42:05.799-0600 [DEBUG] provider.terraform-provider-azurerm_v3.91.0_x5: GET https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.ApiManagement/service/APIM_SERVICE/namedValues/backend-eastus2-1?api-version=2022-08-01: timestamp=2024-02-12T14:42:05.799-0600

2024-02-12T14:42:06.157-0600 [DEBUG] provider.terraform-provider-azurerm_v3.91.0_x5: AzureRM Response for https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.ApiManagement/service/APIM_SERVICE/namedValues/backend-eastus2-1?api-version=2022-08-01: 
    HTTP/2.0 200 OK
    Content-Length: 717
    Cache-Control: no-cache
    Content-Type: application/json; charset=utf-8
    Date: Mon, 12 Feb 2024 20:42:05 GMT
    Etag: "AAAAAAACJbk="
    Expires: -1
    Pragma: no-cache
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Cache: CONFIG_NOCACHE
    X-Content-Type-Options: nosniff
    X-Ms-Correlation-Request-Id: 8f5d5c33-1da7-805c-f91c-3983a618e726
    X-Ms-Ratelimit-Remaining-Subscription-Reads: 11996
    X-Ms-Request-Id: 8f5d5c33-1da7-805c-f91c-3983a618e726
    X-Ms-Routing-Request-Id: EASTUS2:20240212T204206Z:41871143-5834-4669-a47f-c214d71b6624
    X-Msedge-Ref: Ref A: 7EA15F101DF542AF87DEA47FD5643F79 Ref B: MNZ221060610051 Ref C: 2024-02-12T20:42:06Z

    {
      "id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.ApiManagement/service/APIM_SERVICE/namedValues/backend-eastus2-1",
      "type": "Microsoft.ApiManagement/service/namedValues",
      "name": "backend-eastus2-1",
      "properties": {
        "displayName": "backend-eastus2-1",
        "keyVault": {
          "secretIdentifier": "https://KEYVAULT_NAME.vault.azure.net/secrets/backend-eastus2-1-primary-access-key/SECRET_ID",
          "identityClientId": null,
          "lastStatus": {
            "code": "Success",
            "timeStampUtc": "2024-02-12T18:48:08.2879659Z"
          }
        },
        "tags": null,
        "secret": true
      }
    }: timestamp=2024-02-12T14:42:06.157-0600

2024-02-12T14:42:06.158-0600 [ERROR] provider.terraform-provider-azurerm_v3.91.0_x5: Response contains error diagnostic: diagnostic_severity=ERROR tf_proto_version=5.4 tf_provider_addr=provider tf_resource_type=azurerm_api_management_named_value tf_rpc=ValidateResourceTypeConfig diagnostic_summary=""display_name" may only contain alphanumeric characters, periods, underscores and dashes" @module=sdk.proto diagnostic_detail= @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 tf_req_id=07e28b3f-53da-e693-ec11-c3bfff34f774 diagnostic_attribute=AttributeName("display_name") timestamp=2024-02-12T14:42:06.158-0600
2024-02-12T14:42:06.158-0600 [ERROR] vertex "azurerm_api_management_named_value.backend-eastus2-1" error: ""display_name" may only contain alphanumeric characters, periods, underscores and dashes"

Shows that the AzureRM API returns 200 successfully and that our module is setting the display name to backend-eastus2-1. However, the validation still fails with "display_name" may only contain alphanumeric characters, periods, underscores and dashes".

arjundevane commented 8 months ago

Introduced in https://github.com/hashicorp/terraform-provider-azurerm/pull/24749, and release 3.91.0.

Since this is a potentially breaking change, should there be an opt-in mechanism for existing code? With a default of false.

Felix-Franz commented 8 months ago

Duplicate of #24831, was fixed and merged to main with #24832.

rcskosir commented 8 months ago

@antgustech Thanks for taking the time to open this issue. @Felix-Franz Thank you for helping find the duplicate as well as the PR that has been merged to fix this issue. As such, I am going to mark this issue as closed with #24832 which should go out with v3.92.

github-actions[bot] commented 6 months ago

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.