运行 Terraform 配置程序“local-exec”时出错

问题描述 投票:0回答:1

当我执行下面的代码时,我收到错误。

resource "null_resource" "enable-usage-plan" {

  triggers = {
    usage_plan_id = "cd8lab"
  }


  provisioner "local-exec" {
    command = "aws apigateway update-usage-plan --usage-plan-id cd8lab --patch-operations op ="add",path="/apiStages",value="7tdnnlppg1:poc""
  }

错误:-

│ 错误:参数后缺少换行符 │ │ 在 main.tf 第 9 行,资源“null_resource”“enable-usage-plan”中: │ 9: 命令 = "aws apigateway update-usage-plan --usage-plan-id sx8lzu --patch-operations op="add",path="/apiStages",value="7tdnnlppg1:poc"" │ │ 参数定义必须以换行符结尾。

当我在 AWS CLI 上运行相同的命令时,该命令运行正常。

amazon-web-services terraform null aws-api-gateway terraform-provider-aws
1个回答
0
投票

你必须转义你的字符串:

resource "null_resource" "enable-usage-plan" {

  triggers = {
    usage_plan_id = "cd8lab"
  }


  provisioner "local-exec" {
    command = "aws apigateway update-usage-plan --usage-plan-id cd8lab --patch-operations op =\"add\",path=\"/apiStages\",value=\"7tdnnlppg1:poc\""
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.