-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_api
does not properly follow up when Azure responds with 202
#24379
Comments
Hi @Sefriol thanks for opening this issue. In order to find the root cause, a TF configuration file (containing dependent resources and variable values) and detailed steps would be of great help in quickly reproducing/troubleshooting the issue. Could you please provide the complete TF configuration and detailed repro steps to help reproduce this issue? Thanks in advanced. In addition, could you please clarify that why do you think "terraform does not use the location URL to check whether resource update was successful"? |
When terraform updates an API it uses However, when OpenAPI spec is provided from external URL (i.e. If the OpenAPI spec is invalid, this can fail. However this failure does not seem to be reported anywhere else in Azure (Activity Log etc tells that operation succeeded). If processing this OpenAPI spec fails, it this URL in I will try to figure out if there is a simple TF config that could be used to replicate this. I had an issue where there were 2 APIs with same display name and it failed to update because of that. Terraform and Azure did not otherwise report this as failure, but I noticed that the OpenAPI spec was not updated in APIM. I am not sure which kind of errors will cause operation failure specifically. |
Thanks for the explanation. First of all, I would like to explain that if the In addition, Terraform does not perform validity verification on the content of |
From my understanding, they are not the same.
This is fine. This should be exactly what the Location URL does. EDIT: Example response from Location URL: STATUS: 400 {
"error": {
"code": "ValidationError",
"message": "One or more fields contain incorrect values:",
"details": [
{
"code": "ValidationError",
"target": "ApiVersion",
"message": "Can't set VersionName when ApiVersionSetId is not set."
}
]
}
} EDIT 2: We have also made a ticket about this for Microsoft since Activity Log should report this failure. |
In the support call, we noticed, that these OpenAPI spec errors are same which would appear in the UI if you tried to import it manually. However, it seems that it will process it locally while through API it will process in cloud. UI leaves no mark in the activity log while API leaves "Accepted" and sometimes "Succeeded", when update process fails. Microsoft will follow up us on whether this is intended that it won't show up in Activity Log or not. |
Microsoft kinda stated that this is working as intended since error does not actually happen in the portal, but in a subprocess that validates the OpenAPI spec. We didn't really agree with this, but we'll see if something comes up. However the logic behind the terraform process should be adjusted to fix this issue regardless. |
Yeah, this improper validation is causing us all sorts of problems. Here's a very simple repro of the issue. I created a basic First apply fails:
Second apply succeeds and terraform reports no changes:
If you then go into the UI to view the OpenAPI spec it shows this:
I set In the meantime, I think we're going to start validating the OpenAPI specs with an |
Nice that you found a simple way to reproduce this issue! Also to note that validating OpenAPI spec is not enough since update process can fail on APIM specific issues (like trying to create two APIs with the same spec). |
Final response from Microsoft on the issue:
|
I mean, documentation change does not really fix the problem? Provider should use the proper follow-up url to check whether update succeeds or fails. |
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. |
Is there an existing issue for this?
Community Note
Terraform Version
1.5.2
AzureRM Provider Version
3.85
Affected Resource(s)/Data Source(s)
azurerm_api_management_api
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Currently terraform does not use the location URL to check whether resource update was successful. There is a flaw in APIM resources where operation can be claimed to be successful, but actual error shows up in the location url and location URL responds with 400.
Actual Behaviour
Currently terraform reports operation to be succesful, even though nothing is actually updated.
Steps to Reproduce
Important Factoids
No response
References
APIM Create or Update API
The text was updated successfully, but these errors were encountered: