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.6k stars 4.65k forks source link

min_api_version in resource azurerm_api_management is not working consistently #22998

Open alinuxguru70 opened 1 year ago

alinuxguru70 commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.5.5

AzureRM Provider Version

3.69.0

Affected Resource(s)/Data Source(s)

azurerm_api_management

Terraform Configuration Files

Setting the min_api_version to the default value "2019-12-01" works fine

resource "azurerm_api_management" "apim" {
  min_api_version      = "2019-12-01"
...
}

the apiVersionConstraint is properly set 

"apiVersionConstraint": {
            "minApiVersion": "2019-12-01"
        },

The value "Prevent users with read-only permissions from accessing service secrets" is properly set to "Yes" in the interface.

Setting the min_api_version to the value "2021-08-01" has mixed success

resource "azurerm_api_management" "apim" {
  min_api_version      = "2021-08-01"
...
}

The apiVersionConstraint is properly set.

"apiVersionConstraint": {
            "minApiVersion": "2021-08-01"
        },       

The value "Prevent users with read-only permissions from accessing service secrets" remains unmodified and remains set to "No" in the interface.

Setting the min_api_version to any value above "2021-08-01" results in total failure.

resource "azurerm_api_management" "apim" {
  min_api_version      = "2022-08-01"
...
}

A 400 error message is generated when the apply operation occurs.   This is because the terraform azurerm provider is attempting to call the APIM management backplane using the 2021-08-01 api.   We need to be able to set the min_api_version to "2022-08-01", which the provider cannot do.

https://management.azure.com:443/subscriptions/..../resourceGroups/.../providers/Microsoft.ApiManagement/service/.....?api-version=2021-08-01

Debug Output/Panic Output

2023-08-14T16:29:44.139Z [ERROR] provider.terraform-provider-azurerm_v3.69.0_x5: Response contains error diagnostic: tf_req_id=79df9d9c-ff7d-f773-ceb1-df8e5a2214fe diagnostic_detail= diagnostic_summary=" setting Sign In settings for Api Management: (Service Name "...." / Resource Group "..."): apimanagement.SignInSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="MissingOrIncorrectVersionParameter" Message="API version query parameter is not specified or was specified incorrectly.  Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview  Example query param format: api-version=SupportedVersion"" tf_proto_version=5.3 diagnostic_severity=ERROR tf_provider_addr=provider tf_resource_type=azurerm_api_management tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto timestamp=2023-08-14T16:29:44.139Z

Expected Behaviour

Setting the version 2022-08-01 and the "Prevent users with read-only permissions from accessing service secrets" is set to "Yes"

Actual Behaviour

No longer able to communicate wit the APM instance

2023-08-14T16:29:44.139Z [ERROR] provider.terraform-provider-azurerm_v3.69.0_x5: Response contains error diagnostic: tf_req_id=79df9d9c-ff7d-f773-ceb1-df8e5a2214fe diagnostic_detail= diagnostic_summary=" setting Sign In settings for Api Management: (Service Name "...." / Resource Group "..."): apimanagement.SignInSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="MissingOrIncorrectVersionParameter" Message="API version query parameter is not specified or was specified incorrectly. Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview Example query param format: api-version=SupportedVersion"" tf_proto_version=5.3 diagnostic_severity=ERROR tf_provider_addr=provider tf_resource_type=azurerm_api_management tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto timestamp=2023-08-14T16:29:44.139Z

Steps to Reproduce

code snippets are provided above

Important Factoids

No response

References

No response

christy700 commented 1 year ago

I am also having the same issue. Did you find any fix for this?

juvenalguevara commented 1 year ago

having the same behavior using 3.65.0 provider.

AndriyDmytrenko commented 11 months ago

It seems that 3.80 works well.

MonzT commented 4 months ago

Trying to create an instance of apim with the following min_api_version:

get a 400 BadRequest error stating:

azurerm version:

It's as though it's completely ignoring the version altogether. Creating the APIM manually in the portal show that api version 2022-09-01 is being used, but trying to use this version in terraform causes the same issue above. Help?