You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
variable"swagger_file" {
type=stringdescription="The swagger file to use to deploy the API."
}
resource"azurerm_api_management_api""api" {
name="test-apim"resource_group_name="rg"api_management_name="apim-test"revision="1"display_name="test"path="test/test"protocols=["https"]
subscription_required=falseimport {
content_format="openapi+json"content_value=file(var.swagger_file)
}
}
Debug Output/Panic Output
Deploy the API with swagger1.json for the first time: OK
Deploy the API with swagger2.json for the first time:
azurerm_api_management_api.api: Modifying... [id=/subscriptions/XXX/resourceGroups/rg/providers/Microsoft.ApiManagement/service/apim-test/apis/test-apim]azurerm_api_management_api.api: Still modifying... [id=/subscriptions/XXX-...test/apis/test-apim, 10s elapsed]...azurerm_api_management_api.api: Still modifying... [id=/subscriptions/XXX-...test/apis/test-apim, 4m0s elapsed]╷│ Error: waiting on creating/updating Api: (Name "test-apim" / Service Name "apim-test" / Resource Group "rg"): Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="ValidationError" Message="One or more fields contain incorrect values:" Details=[{"code":"ValidationError","message":"Operation with the same method and URL template already exists: GET, /path1","target":"urlTemplate"},{"code":"ValidationError","message":"Operation with the same method and URL template already exists: GET, /path1","target":"method"}]││ with azurerm_api_management_api.api,│ on api.tf line 1, in resource "azurerm_api_management_api" "api":│ 1: resource "azurerm_api_management_api" "api" {│╵
Deploy the API with swagger2.json for the second time: OK
Expected Behaviour
When applying the manifests with swagger2.json for the second time, I expect to have the same error as when applying for the first time.
Actual Behaviour
Actually, when applying the manifests with swagger2.json for the second time, there is no error.
However, the error is present when using az to deploy the swagger2.json for the second time (as expected):
az apim api import -g "rg" --service-name "apim-test" --path "test/test" --specification-format "OpenApiJson" --api-id "test-api" --specification-path "swagger2.json"
Result:
(ValidationError) One or more fields contain incorrect values:Code: ValidationErrorMessage: One or more fields contain incorrect values:Exception Details: (ValidationError) Operation with the same method and URL template already exists: GET, /path1 Code: ValidationError Message: Operation with the same method and URL template already exists: GET, /path1 Target: urlTemplate (ValidationError) Operation with the same method and URL template already exists: GET, /path1 Code: ValidationError Message: Operation with the same method and URL template already exists: GET, /path1 Target: method
Steps to Reproduce
terraform apply -var swagger_file=swagger1.json # OK
terraform apply -var swagger_file=swagger2.json # Get an error (because we are modifying an existing operationId)
terraform apply -var swagger_file=swagger2.json # OK
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Provider ignores APIM error when importing an invalidate swagger for the second time
Provider ignores APIM error when importing an invalid swagger for the second time
Jun 5, 2023
We have this error very often and I just ran into it today again. So, any plans to fix this at some point?
It seems that the state is erroneously updated despite the Azure APIM API actually returned an error and so the API got actually not updated.
This behavior is very very unintuitive because the second time the config just applies with "No changes".
In additional the fact that the actual error mess is just cut off by Terraform makes troubleshooting also unscary difficult. Normally in the error message the reason why the api definition is invalid is shown. But this very relevant part of the error message gets just cut off by terraform/azurerm.
Not sure if this would fix also this issue. But I assume not entirely. Because in this case we get the error message but somehow the state is updated despite the error and the interesting part of the error is also chopped in the screenshots of your PR.
So, I assume this issue here need some other/additional fix. Or what do you think?
Is there an existing issue for this?
Community Note
Terraform Version
1.4.6
AzureRM Provider Version
3.59
Affected Resource(s)/Data Source(s)
azurerm_api_management_api
Terraform Configuration Files
swagger1.json
file:swagger2
file:Manifests:
Debug Output/Panic Output
Deploy the API with
swagger1.json
for the first time: OKDeploy the API with
swagger2.json
for the first time:Deploy the API with
swagger2.json
for the second time: OKExpected Behaviour
When applying the manifests with
swagger2.json
for the second time, I expect to have the same error as when applying for the first time.Actual Behaviour
Actually, when applying the manifests with
swagger2.json
for the second time, there is no error.However, the error is present when using
az
to deploy theswagger2.json
for the second time (as expected):Result:
Steps to Reproduce
terraform apply -var swagger_file=swagger1.json
# OKterraform apply -var swagger_file=swagger2.json
# Get an error (because we are modifying an existing operationId)terraform apply -var swagger_file=swagger2.json
# OKImportant Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: