获取“cli-input-json”:收到无效的 json”

xvz*_*vzf 10 json amazon-web-services amazon-ecs amazon-vpc aws-fargate

我正在尝试在 AWS ECS 中使用 Fargate 启动类型运行服务。以下是我的 service-definition.json 文件。

{
  "serviceName": "MyService",
  "cluster": "arn of my cluster",
  "launchType": "FARGATE",
  "deploymentConfiguration": {
    "maximumPercent": 200,
    "minimumHealthyPercent": 0
  },
  "desiredCount": 1,
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "assignPublicIp": "DISABLED",
      "securityGroups": [
        "sec-group-id"
      ],
      "subnets": [
        "subnet-1",
        "subnet-2"
      ]
    }
  },
  "taskDefinition": "mytask",
  "loadBalancers": [
    {
      "containerName": "mytask-container",
      "containerPort": 8080,
      "targetGroupArn": "arn to my target group"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

运行此命令时 aws ecs create-service --cli-input-json service-definition.json:我收到无效的 json 错误。

我已经验证了 json 的语法。我只是想确认这个定义在逻辑上是否“可以”工作?如果不对,欢迎指正。

Mar*_*cin 22

当你想使用一个文件时,你必须使用以下格式(file://cli-input-json

aws ecs create-service --cli-input-json file://service-definition.json
Run Code Online (Sandbox Code Playgroud)

示例位于创建服务文档中。