找不到 Azure APIM 的 Terraform 自签名证书

Terraform self signed certificates for Azure APIM cannot find

我有一些自签名证书,我想将其用于 APIM managementdeveloperproxy 域,如下所示:

但是我收到这个错误:

creating/updating API Management Service "jananath-apim" (Resource Group "apim-appGw-RG"): apimanagement.ServiceClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameters" Message="Invalid parameter: Invalid certificate associated with DeveloperPortal. Error Message: Cannot find the requested object.\r\n."

这是我的地形代码:

apim.tf

resource "azurerm_api_management" "example" {
  name                = "jananath-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "Contoso"
  publisher_email     = "jbjayarathna@gmai.com"

  sku_name = "Developer_1"
  virtual_network_type = "Internal"
  
  virtual_network_configuration {
    subnet_id = azurerm_subnet.apimSubnet.id
  }

  hostname_configuration {

      management {
        host_name                    = var.managementHostname  
        certificate                  = base64encode("jananath-ssl.pfx")
        certificate_password         = var.managementCertPfxPassword       
      }

      developer_portal {
        host_name = var.portalHostname  
        certificate                  = base64encode("jananath-ssl.pfx")
        certificate_password         = var.portalCertPfxPassword    
      }

      proxy {
        host_name = var.gatewayHostname 
        certificate                  = base64encode("jananath-ssl.pfx")
        certificate_password         = var.gatewayCertPfxPassword       
      }
  }
}

并且 jananath-ssl.pfxapim.tf

位于同一路径

我做错了什么?有人可以帮助我吗?

base64encode 只是将字符串覆盖为 base64。它不读取 实际文件。要阅读您必须使用的文件:

base64encode(file("jananath-ssl.pfx"))

filebase64:

filebase64("jananath-ssl.pfx")