The azurerm_api_management_api is missing support for OpenAPI v3 JSON and YAML imports in
provider version v1.24.0. Please add "openapi", "openapi+json" and "openapi-link" to the allowed content formats.
resource "azurerm_resource_group" "test" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_api_management" "test" {
name = "example-apim"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
publisher_name = "My Company"
publisher_email = "[email protected]"
sku {
name = "Developer"
capacity = 1
}
}
resource "azurerm_api_management_api" "test" {
name = "example-api"
resource_group_name = "${azurerm_resource_group.test.name}"
api_management_name = "${azurerm_api_management.test.name}"
revision = "1"
display_name = "Example API"
path = "example"
protocols = ["https"]
import {
content_format = "openapi-link"
content_value = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"
}
}
hey @mhennecke
Thanks for opening this issue :)
Taking a look into this it appears this requires an upgrade to the version of the Azure API we're using - we've got an upstream issue open requesting that here (which I've just requested an update for), but once that becomes available in the Azure SDK for Go (which is generated from that repo) we can look to add support for this ๐
Thanks!
๐
The upstream issue's been fixed: https://github.com/Azure/azure-rest-api-specs/issues/4409 - once the SDK's been updated #3335 we should be able to go to the new version of the API Management API - at which point it should be possible to add support for this
Thanks!
hey @tombuildsstuff,
Any plans on this? :)
cc. @katbyte
Do you have any plans on implementing this?
I tried to do it but it seems like it requires updating azure-sdk-for-go to version 31.2.0 and autorest to 0.5.0, and updating everything to api version 2019-01-01, but it became too complicated.
/cc. @maximbaz
Hei. Im intressed in this feature. Im working for Norway welfare and is in need for this, as we are exposing apis with the use of Azure Api-management. I would like to build the infrastructure with terraform.
Any updates on the upgrade of the version of the Azure API?
please hit me back
thanks
@ybelMekk @AndiA92 unfortunately we're still blocked on https://github.com/Azure/azure-rest-api-specs/issues/6372
Once the Swagger's been fixed / the new API is available we should be able to add support for this - but unfortunately there's not a lot we can do until that's resolved.
Thanks!
@tombuildsstuff Hi Tom, is this issue blocking importing an OpenAPI specification using Terraform?
The above can be done using Powershell and ARM already.
@molinch yep - we're still waiting on the API Team to publish a Swagger document (which in turn generates a Go SDK for us to use) for the new API version
Any updates on this or possibly a timeframe?
Latest is:
https://github.com/Azure/azure-rest-api-specs/issues/6372#issuecomment-571308516
Just for information. I've forked the provider on my side, and I've managed to used openapi3 json and yaml.
I think I will not do a PR since I don't have time to properly check inetgration test and if I didn't break something in the process, but here it what I've done :
For reference, here is the list
https://github.com/Azure/azure-sdk-for-go/blob/91316876b14205b98fc116bba77b3bb689746954/services/apimanagement/mgmt/2019-01-01/apimanagement/models.go#L205
Then you can go build
and name your custom plugin like terraform-provider-custom
. Put the provider in your project folder.
You will able to import it like
provider "azurerm" {
version = "=1.42.0"
}
provider "custom" {
}
and then use it just for your resource like
resource "azurerm_api_management_api" "foobar" {
provider = custom
name = "foobar"
import {
content_format = "openapi"
content_value = file("${path.module}/api-schema/openapi_openapi.yml")
}
}
I hope it will help some people ๐
Since it's go, I can cross-compile the forked plugin for people if you don't want to re-fork it. Tell me.
PS. The fork is on an internal gitlab server, so I can't directly share the repo...
@tombuildsstuff the Azure go sdk has been updated, do you have a timeline on when the Provider will be updated? Just wanting to know if we should pursue the steps @PPACI outlined above or wait for the official fix.
Thx for the great work so far :-)
It isn't from what I can tell?
https://github.com/Azure/azure-sdk-for-go/tree/master/services/apimanagement/mgmt
changes were in 2019-12-01-preview:
https://github.com/vfedonkin/azure-rest-api-specs/blob/87c99392a06f3fbfde0507d9c802c17aac48414a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2019-12-01-preview/apimapis.json
It has now been updated, released in 39.1.0 of the azure sdk for go https://github.com/Azure/azure-sdk-for-go/pull/7317
Any progress on this?
When I set content_format as "swagger-link-json" and try to import an openapi v3 spec file, I get the following error:
StatusCode=404 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
Is there a workaround to this?
I am also seeing "The Swagger version specified is unknown" when trying to upload an open api v3 document, until the openapi-link content_format is supported we will continue to use V2 swagger
Is this one closed any day soon? ๐
@tombuildsstuff , Azure API stopped support on exporting Swagger-json format from the portal. Which means only way to update the existing API's in the APIM is through openAPI format from Terrafrom. This is now high priority.
@tombuildsstuff There were a number of updates recently merged into the https://github.com/Azure/azure-rest-api-specs repo, and it looks like the Go SDK has been updated as well based on the last comment on the issue that was marked as blocking this one: https://github.com/Azure/azure-rest-api-specs/issues/4409
I'd began work on the addition of the OAS v3 content-formats, but realized that this is a much larger undertaking than originally expected.
The current set of API Management related azurerm code uses the 2018-01-01 version of APIM, and the OASv3 content-formats were added in version 2019-01-01. The azurerm provider now uses version 41.0.0 of the Azure SDK for Go, which added support for APIM versions 2018-06-01-preview, 2019-01-01, and 2019-12-01-preview, so the addition of the OASv3 content-formats is indeed possible.
In order to make the change to allow the new content-formats on the API resource, however, the entire azurerm codebase for API Management needs to be updated to utilize 2019-01-01. As soon as the version is updated, it breaks clients and other resources downstream. The upgrade to the new version of APIM cannot be limited to the API resource type only. Even if it was possible to limit the changes to the API resource without causing other errors, Iโm not sure that the Terraform team would accept a PR that causes the set of API Management resources to use multiple versions and be out of sync with each other. It will all need to be updated simultaneously.
@lucashuet93 - i merged in a PR to upgrade to 2019-12-01 a couple days ago so this should be unblocked now ๐
@katbyte Awesome to hear! I've now opened PR #6618 which fixes this issue.
This has been merged with #6618 and should make it into v2.8.0 of the provider
This has been released in version 2.8.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:
provider "azurerm" {
version = "~> 2.8.0"
}
# ... other configuration ...
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error ๐ค ๐ , please reach out to my human friends ๐ [email protected]. Thanks!
Most helpful comment
It has now been updated, released in 39.1.0 of the azure sdk for go https://github.com/Azure/azure-sdk-for-go/pull/7317