-
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_schema doesn't work with JSON schemas #10066
Comments
Do you have a workaround for this? I'm trying to either make my own ARM template to create this or do some az cli commands to get this automated. |
The So I actually figured out a way to do this using ARM templates: locals {
api_version_set_id_split = split("/", azurerm_api_management_api.api.version_set_id)
api_schema_id = element(local.api_version_set_id_split, length(local.api_version_set_id_split) - 1)
}
resource "azurerm_resource_group_template_deployment" "api_management_schema" {
deployment_mode = "Incremental"
name = "api_management_schema"
resource_group_name = var.resource_group
parameters_content = jsonencode({
apim_name = {
value = data.azurerm_api_management.apim.name
}
apim_api_name = {
value = "apim-name"
}
api_schema_id = {
value = local.api_schema_id
}
})
template_content = file("./api_management_schema.json")
tags = local.common_tags
} api_management_schema.json{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apim_name": {
"type": "string"
},
"apim_api_name": {
"type": "string"
},
"api_schema_id": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.ApiManagement/service/apis/schemas",
"apiVersion": "2021-08-01",
"name": "[concat(parameters('apim_name'), '/', parameters('apim_api_name'), '/', parameters('api_schema_id'))]",
"properties": {
"contentType": "application/vnd.oai.openapi.components+json",
"document": {
"components": {
"schemas": { ... }
}
}
}
}
]
} |
Is is also to consider that while the schema is deployed in this "broken" state (as mentioned in original post), the "schema definitions" part of API Management seems to get broken as well. I did not manage to create additional schema definitions anymore via portal (endless loop). Removing the broken schema resources in terraform code was the only way to get it back to a working state. Would be really nice to see a fix here. @jz-wilson Thank you very much for sharing the work-around, it fits for me as well. |
This issue is still blocking the creation and usage of new API schemas. Any updates about fixing this? |
Experiencing the same issue with |
It looks like #18394 may help |
I believe I'm having the same problem. Question has been asked on Stack Overflow along with steps to recreate: |
Community Note
Terraform (and AzureRM Provider) Version
terraform 0.14.3
terraform-provider-azurerm 2.41.0
Affected Resource(s)
azurerm_api_management_api_schema
Terraform Configuration Files
Expected Behaviour
MyDefinition
should appear in Azure's APIM definitions for my API.Actual Behaviour
The definition doesn't get created. The schema resource was created in a broken state.
Steps to Reproduce
terraform apply
(given that you have created some stub dependencies)
Important Factoids
I've noticed that the ARM template that gets created by Terraform is wrong for JSON schemas. According to the documentation, the
document
field can be one of these two elements:value
that is of type string (meant for anything other than JSON)definitions
that is of type object (meant for JSON schemas). This is the broken (unsupported) scenarioI can see two obvious solutions to this problem:
content_type
and then decide if Terraform is going to create a template withvalue
as a string ordefinitions
as an objectdefinitions
that will serialize to the definitions object and have Terraform forbid that bothvalue
anddefinitions
is setReferences
https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/service/apis/schemas#SchemaContractProperties
The text was updated successfully, but these errors were encountered: