'Tag an API in Azure API Management with Terraform
I'm trying to IaC my API Gateway using Terraform. I did all configurations normally, such as backend, products and policies. But reading the documentation, I didn't find any way to set a Tag to API, only create a new one.
resource "azurerm_api_management_api" "test" {
name = "test*******"
display_name = "Test*******"
api_management_name = data.azurerm_api_management.example.name
resource_group_name = data.azurerm_api_management.example.resource_group_name
revision = "1"
protocols = ["https"]
subscription_required = true
path = "test****"
subscription_key_parameter_names {
header = "Ocp-Apim-Subscription-Key"
query = "subscription-key"
}
}
Am I missing something? Does Terraform support this feature? Is it better to use ARM templates or Powershell in this case?
Solution 1:[1]
We were missing this feature as well.
Luckily, it got added to the azurerm Terraform provider in version 0.92.0 recently: azurerm_api_management_api_tag
You can use the new resource to assign an existing tag to an API:
resource "azurerm_api_management_api" "example" {
name = "example-api"
resource_group_name = azurerm_resource_group.example.name
api_management_name = azurerm_api_management.example.name
revision = "1"
}
resource "azurerm_api_management_tag" "example" {
api_management_id = data.azurerm_api_management.example.id
name = "example-tag"
display_name = "Example Tag"
}
resource "azurerm_api_management_api_tag" "example" {
api_id = azurerm_api_management_api.example.id
name = "example-tag"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andreas Siegel |

