-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Unable to create azurerm_api_management_api with imported content file with azurerm > 3.69.0 #23322
Comments
It looks like the PR didn't solve the problem. It still occurs to me on v3.75.0. Can we reopen this issue or should I make a new one? |
It worked for me after using v3.75.0. |
I also have this issue, also when using AzureRM provider in version 3.75.0 (mbfrahry FYI) |
@zhallgato, @mennlo, @DominikKrissVisma Thank you for the update, I will reopen this issue. |
Hey @sinbai, mind taking another look at this one? |
Hi @DominikKrissVisma, @zhallgato , sorry that PR could not solve your problem. Since the PR already addressed mennlo's issue , I assume that your case might be different. Is it possible to provide detailed terraform configuration (easily reproducible and contains variable values - except sensitive information) and reproduce steps to help reproduce and resolve the problem? In addition, it might help a lot if Terraform trace logs could also be provided. Thanks in advance. |
hello,
the issue is that API is actualy created during that run, but not tracked in the TF state file, therefore after this happes we need to import the API into state file. |
This issue still persists in 3.80, I had to downgrade to 3.68 for the resource to create. Any timeline to fix this issue? |
I tried to work-around this by downgrading from 3.80 to 3.68 but it seems the state is no longer compatible, so it's not the easiest work-around. I get a bunch of │ The current state of azurerm_api_management_product_policy.<policyName>
│ was created by a newer provider version than is currently selected. Upgrade
│ the azurerm provider to work with this state.
│ The current state of azurerm_api_management_api_policy.<policyName>
│ was created by a newer provider version than is currently selected. Upgrade
│ the azurerm provider to work with this state. Sorry for the noise :-) |
@sinbai looks like the original PR didn't resolve this issue - since you sent the original PR to fix this, can you take another look into this one? Thanks! |
Can anyone here provide more contexts in terms of step-by-step-repro-this-issue? |
I can probably make one, but I can't make the time the next couple of days. I can start by sharing some more information about the resource were this issue occurred to me on azurerm 3.80, though. The resource looks like this resource "azurerm_api_management_api" "api" {
name = "clientname-${var.env}-api-${var.api_name}" # e.g. "clientname-d-api-clientapi-internal"
api_management_name = var.api_management_name # e.g. "clientname-d-apim-common"
resource_group_name = var.resource_group_name # e.g. "clientname-d-rg-common"
revision = var.revision # e.g. "50923", "50930", ...
display_name = var.display_name # e.g. "clientname clientapi internal dev"
path = "${var.api_name}" # e.g. "clientapi"
protocols = ["https"]
subscription_required = var.subscription_required # e.g. true
service_url = var.service_url # e.g. https://clientname-d-aks.norwayeast.cloudapp.azure.com/clientapi
import {
content_format = "openapi"
content_value = file(var.openapi_definition) # a fairly ordinary OpenAPI v3 spec in json format
# with info.version set to "internal"
}
lifecycle {
# The version number is pulled from the BUILD_ID, so it changes constantly.
# This will only update if the actual API has changed.
ignore_changes = [revision]
}
} We have just one azurerm_api_management_api resource with this name+api_management_name, |
I have some new information. We had 6 APIMs in different environments (4 of them in East US and 2 of them in East US 2 Azure regions). We only experienced the above-mentioned issue on those APIMs which were in East US 2 region. So, we recreated these two APIMs in East US, and since the recreation we no longer experience the issue. Everything works fine. Maybe the issue is related only to specific Azure regions. (maybe there are some delays in these regions?) |
This is happening to me too. We are in US East 2 as well and running azurerm 3.80. We are also importing a fairly large openapi definition. |
For us, it seems to happen when trying to add apis with "large" (openapi) definition files (+300KB, +90 operations). Smaller definition files worked fine, and reverting to 3.69.0 works for everything. Location Norway East. |
I really appreciate everyone's help. It has been reproduced and is under investigation. Thank you so much! |
I am hitting this issue as well, on |
Hi @tombuildsstuff I assume that this is a base layer issue. For the case of long running operation poller and the API return |
Same (and as well with 3.92.0) |
I am currently getting this on provier version 3.98.0 |
I have just moved from 3.89 to 3.98 in an attempt to fix this issue, but to no avail: Error: creating/updating Api (Subscription: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" I'd really appreciate a fix or a work-around, please. I have literally hundreds of Function Apps to deploy into APIM |
@deankelly780 did you get any solution for this? The strange part is when i run the terraform apply again then it works in second time. |
No @sharatbhaskar1988 nothing yet. I am still working on it. If I come up with something, I'll ping it here. The failure pattern seems different for me: I am currently developing the TF by deploying 2 x APIs and one works every time, but the other fails every time. |
@sinbai Are you able to take another look at this issue? Thanks! |
@manicminer and @sharatbhaskar1988 - I seem to have a solution that at least worked for my particular version of this issue. When I was deploying, I was using two copies of a mostly identical template to create two different APIs. The only differences were the names of the Function Apps. Both templates were using the same setting for "path":
By ensuring that "path" was set differently in both templates the problem went away. I hope this is useful to you. |
@manicminer thanks for your PR. Due to testing locally with the following TF configuration, the reproducible situation mentioned in issue #740 (This error occurs when the API returns a 404 error during the first polling. If the polling API returns 200 for the first time, the problem could not be reproduced) did not occur (After trying several times, the API did not return 404.), I'm not sure why the issue still occurs after applying the PR.
However, it could be seen from the following log provided by ltmleo that TF polls the
Regardless, since the issue could not be reproduced, the root cause could not be located. If anyone here could provide the minimum reproducible TF configuration, repro steps and TF Log information, it would be of great help for us to troubleshoot. |
@sinbai : When an invalid open api file is used, terraform 3.98 still fails with 404. openapi:
last couple of lines in the terraform log
It is not clear to me whether azurerm or some of its libraries actually calls the Location |
Hi @mrickly thank you very much for the information, I could reproduce your situation. I have filed an Terraform SDK issue to track it. Could you please track it for more updates? |
Thank you @sinbai , I will track the new issue. |
@deankelly780 i have an open api doc which have different paths like /a/b/c and /d/e/f. Not sure what should i set in the path property. |
@sinbai I just want to let you know that this error can happens during the initial deployment (terraform apply) of an API also. When the API is a bit more complex meaning the api has a lot of resources etc. the creation of the API on the API Management can take some time. In such a case also the wrong polling URL is used and the creation of the API fails also with an 404 error. Even tough the API is actually created on the API Management. Any subsequent deployment will then succeed because the API is actually already created on the API Management. In the TF_TRACE Log the root cause is good recognizable: Frist the correct PUT request to create the API is made:
For wich the Azure response correctly contents the
But then instead that the URL from the
Consequently Azure response then with 404 which lead then to the failure of the deployment:
So I think this will get probably also fixed with hashicorp/go-azure-sdk#962 . |
Seems like I have a workaround for importing new OAS from file into the API in APIM. The workaround also utilizes revisions to make import happen, and it benefits from APIM revisions design. It creates new revision and after import it will "release" it = making it current revision, which is basically "zero downtime" deployment. There is no API recreation with this approach. First we need to create API, with hardcoded revision 1:
This will act as base api containing revision 1. There are no operations yet, those are imported by null_resource using AzureCLI:
First Some remarks:
Hopefully it might be helpfull for some of you guys. |
We have the same issue on North Europe deployment and for big swagger file (more than 600ko). |
We had a similar issue like this. The error from
After a lot of debugging I went to the portal to set up the APIM manually. What I found was that we had exceeded the max amount of operations, error in
We use the So I deleted some of our endpoints to limit the amount of operations we had in dev, and then I was able to run Hope that this will help others. |
This problem is still happening on azurrm 3.107.0 and terraform 1.8.5 However, after some try and error; I noticed it works fine with some changes in the spec yaml file: openapi: 3.0.0
# servers: [] When I reduced my |
Hello, I also have this problem what is the reason here is my module:
|
We also encounter a 404 for huge (> 65.000 lines) yml OAPI Specs. Looks to me as if the PollUntilDone somehow is "impatient". The API deploys in the end and the az cli can successfully fetch the resource about a minute later. Unforunately tf has already decided to stop polling by then. |
This comment was marked as off-topic.
This comment was marked as off-topic.
We also have this issue running 3.116.0. After a lot of trial and error I figured out that if you try to apply the same openAPI file that is already being used in an existing API within the same APIM it will result in a 404 (we have a use case to temporarily have the same openAPI file deployed within the same instance just on a different path). To get around this I deployed the new API with a different openAPI file and then after applying I updated the terraform to use the correct file and change the revision. I also tested the same scenario but through Azure portal manually but couldn't replicate the issue. Azure activity logs also do not show any errors when getting the 404. Hopefully this may help someone! |
Hi @didaskein , @thorbenheins thank you for providing info. From the description, I assume this is another 404 issue. It does not seem to be the same issue as the 404 error caused by #962. Is it possible to provide terraform config (include swagger file/yml OAPI file) that could help repro and troubleshooting? |
Hi @joshblackmoor appreciate your feedback. I am currently following up on the 404 error caused by #962. For your situation, I am not sure if it is related to #962, is it possible to provide terraform config (include openAPI file) and steps to reproduce the symptoms mentioned below to help me troubleshoot?
|
Hi @skycloudnest could you please first verify the validity of the import file (file(var.api_settings.openapi_file_path))? If the import file is incorrect, I assume that your case caused by #962. I am already following up on the fix for # 962. If there is no problem with the import file, could you provide a minimal reproducible TF configuration (including the import file) and repro steps to help reproduce this issue? |
This is still an issue in azurerm 4.3.0. If it's any help, I don't think it's necessarily related to content files. Commenting out the import yields the same error message. And in our case, a subsequent manual Plan and Apply actually created the API but resulted in "polling after CreateOrUpdate: polling failed". Activity logs in Azure reported successfully created API. Next manual Plan and Apply resulted in "already exists - to be managed via Terraform this resource needs to be imported into the State". |
@qfyra And yes, nothing has changed with v4 either and the problem persists now for over a year with no visible progress of improvements. Very very annoying. 😞 |
Is there an existing issue for this?
Community Note
Terraform Version
1.5.7
AzureRM Provider Version
Affected Resource(s)/Data Source(s)
azurerm_api_management_api
Terraform Configuration Files
EXAMPLE managed_apis var:
EXAMPLE test.openapi.yaml
Debug Output/Panic Output
Expected Behaviour
The
azurerm_api_management_api
should be created successfully.I'm trying to create an
azurerm_api_management_api
using an openapi type imported file.Actual Behaviour
With any version
> 3.69.0
, Theazurerm_api_management_api
creation fails with the following error:If you used
<= 3.69.0
the creation is successful.Steps to Reproduce
terraform apply
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: