I’m trying to create a APIM backend with terraform, and it always gives me this error:
module.apim_backends.azurerm_api_management_backend.mssdcontractingcommandsdev: Creating...
╷
│ Error: creating/updating Backend (Subscription: "e*******-ce34-****-****-0151ca9****4"
│ Resource Group Name: "**-**-**-devqa"
│ Service Name: "*******"
│ Backend: "mssdcontractingcommandsdev"): unexpected status 400 (400 Bad Request) with error: ValidationError: One or more fields contain incorrect values:
│
│ with module.apim_backends.azurerm_api_management_backend.mssdcontractingcommandsdev,
│ on ..modulesapimgmtbackendsbackends.tf line 1, in resource "azurerm_api_management_backend" "mssdcontractingcommandsdev":
│ 1: resource "azurerm_api_management_backend" "mssdcontractingcommandsdev" {
The code in the terraform (sending only this part because the others code works, and all variables are correct, I’ve checked multiple times):
resource "azurerm_api_management_backend" "mssdcontractingcommandsdev" {
name = format("%s%s", "mssdcontractingcommands", var.env)
description = format("%s%s", "mssdcontractingcommands", var.env)
api_management_name = var.apim_name
resource_group_name = var.resource_group_name
protocol = "http"
url = format("%s%s%s", "https://***", var.env, ".azurewebsites.net/api")
resource_id = var.contracting_commands_id
tls {
validate_certificate_chain = false
validate_certificate_name = false
}
}
The terraform plan:
+ resource "azurerm_api_management_backend" "mssdcontractingcommandsdev" {
+ api_management_name = "*****"
+ description = "***"
+ id = (known after apply)
+ name = "mssdcontractingcommandsdev"
+ protocol = "http"
+ resource_group_name = "rg-*****-*****-*****"
+ resource_id = "/subscriptions/e*******-ce34-****-****-0151ca9****4/resourceGroups/rg-*****-*****-devqa/providers/Microsoft.Web/sites/mssdcontractingcommandsdev"
+ url = "https://*******.azurewebsites.net"
+ tls {
+ validate_certificate_chain = false
+ validate_certificate_name = false
}
}
The idea is only to create the APIM backend, because the functions pipelines will create the rest through Swagger, like the APIs and the policies
<set-backend-service id="apim-generated-policy" backend-id="mssdcontractingcommandsdev" />
I haven’t tried many things other than that, just some searches.
provider:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.107.0"
}
}
backend "azurerm" {
resource_group_name = "rg-*****-****-devqa"
storage_account_name = "state"
container_name = "tfstatedev"
key = "terraform.tfstate"
}
}
provider "azurerm" {
features {}
skip_provider_registration = true
}
Thomaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.