当我执行下面的代码时,我收到错误。
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 上运行相同的命令时,该命令运行正常。
你必须转义你的字符串:
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\""
}
}