azure 无法确定此terraform应用错误发生的位置

l2osamch  于 2022-11-25  发布在  其他
关注(0)|答案(1)|浏览(105)

当我执行terraform apply时,我得到了以下错误,Error: validating Template Deployment "uksfe-dev-api-office365" (Resource Group "app-sfe-dev-eastus"): requesting validating: resources.DeploymentsClient#Validate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestContent" Message="The request content was invalid and could not be deserialized: 'Error converting value \"sfe-dev-api-office365\" to type 'Azure.Deployments.Core.Definitions.DeploymentParameterDefinition'. Path 'properties.parameters.connections_office365_name', line 1, position 1590.'."。下面是错误引用的资源:

resource "azurerm_resource_group_template_deployment" "office365" {
    name = format( "%s%s-%s-api-office365", var.sfe_names.market, var.sfe_names.product_group, var.sfe_names.environment)
    resource_group_name = module.resource_group.name
        template_content = file("./refScript/logicapp/Office365.json")
        deployment_mode = "Incremental"
        parameters_content = jsonencode({
          "connections_office365_name" = format( "%s-%s-api-office365", var.sfe_names.product_group, var.sfe_names.environment),
          "subscription_id" = data.azurerm_subscription.current.subscription_id
    })
}

下面是上面显示的资源引用的ARM模板文件Office365.json:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "connections_office365_name": {
            "defaultValue": "testoffice365",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('connections_office365_name')]",
            "location": "eastus",
            "kind": "V1",
            "properties": {
                "displayName": "rsgfileexchange@mycompanydomain.com",
                "statuses": [
                    {
                        "status": "Connected"
                    }
                ],
                "customParameterValues": {},
                "nonSecretParameterValues": {},
                "createdTime": "2021-03-25T07:41:30.7103666Z",
                "changedTime": "2021-09-02T19:26:09.2638641Z",
                "api": {
                    "name": "sfe-dev-api-office365",
                    "displayName": "Office 365 Outlook",
                    "description": "Microsoft Office 365 is a cloud-based service that is designed to help meet your organization's needs for robust security, reliability, and user productivity.",
                    "iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1507/1.0.1507.2528/office365/icon.png",
                    "brandColor": "#0078D4",
                    "id": "/subscriptions/dfdbeere-dfda-ghgh-eree-18a838e6ed7a/providers/Microsoft.Web/locations/eastus/managedApis/office365",
                    "type": "Microsoft.Web/locations/managedApis"
                },
                "testLinks": [
                    {
                        "requestUri": "[concat('https://management.azure.com:443/subscriptions/dfdbeere-dfda-ghgh-eree-18a838e6ed7a/resourceGroups/app-sfe-dev-eastus/providers/Microsoft.Web/connections/', parameters('connections_office365_name'), '/extensions/proxy/testconnection?api-version=2016-06-01')]",
                        "method": "get"
                    }
                ]
            }
        }
    ]
}

我认为错误消息的最后一部分说明了错误发生的位置,即Path 'properties.parameters.connections_office365_name', line 1, position 1590.'
任何帮助都将不胜感激。

2guxujil

2guxujil1#

示例here显示了参数按如下方式传递给模板:

parameters_content = jsonencode({
  "vnetName" = {
    value = local.vnet_name
  }
})

因此,您的程式码需要修改如下:

parameters_content = jsonencode({
      "connections_office365_name" = { value = format( "%s-%s-api-office365", var.sfe_names.product_group, var.sfe_names.environment) }
      "subscription_id" = { value = data.azurerm_subscription.current.subscription_id }
})

相关问题