【问题标题】:AWS ECS - Unable to specify service name in cloudformation templateAWS ECS - 无法在 cloudformation 模板中指定服务名称
【发布时间】:2016-12-13 17:18:36
【问题描述】:

我正在尝试使用 cloudformation 模板创建 AWS - ECS 服务

  "service": {
  "ServiceName": "XXX",
  "Type": "AWS::ECS::Service",
  "DependsOn": [
    "AutoScalingGroup"
  ],
  "Properties": {
    "Cluster": {
      "Ref": "ECSCluster"
    },
    "DesiredCount": "1",

    "TaskDefinition": {
      "Ref": "taskdefinition"
    }
  }
},

但是我遇到了一个错误。

Failed: Invalid template resource property 'ServiceName'

我在使用名称/服务名称时遇到了同样的问题。我可以看到 serviceName 是基于文档的参数。但无法弄清楚为什么会失败。如果我不指定名称,它会起作用。但是我需要指定名称,以便我可以在更新服务的不同系统中使用相同的名称。

你能帮忙吗?

【问题讨论】:

    标签: amazon-web-services amazon-ecs amazon-cloudformation


    【解决方案1】:

    这有点令人困惑,但服务名称是由您创建的资源的名称设置的。没有 ServiceName 或 Name 属性。下面将创建一个名为 MyService 的 ECS 服务。

    "MyService": {
      "Type": "AWS::ECS::Service",
      "DependsOn": [
        "AutoScalingGroup"
      ],
      "Properties": {
        "Cluster": {
          "Ref": "ECSCluster"
        },
        "DesiredCount": "1",
        "TaskDefinition": {
          "Ref": "taskdefinition"
        }
      }
    }
    

    显然,如果您在 CloudFormation 模板中引用您的服务,您还需要更新您的引用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 2018-09-17
      • 2019-03-24
      • 2017-08-14
      • 2018-05-18
      • 2015-12-20
      • 2018-11-24
      相关资源
      最近更新 更多