gpt4 book ai didi

amazon-web-services - AWS ECS - 无法在 cloudformation 模板中指定服务名称

转载 作者:行者123 更新时间:2023-12-03 07:21:47 24 4
gpt4 key购买 nike

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

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

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

但是我收到一个错误。

失败:模板资源属性“ServiceName”无效

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

你能帮忙吗?

最佳答案

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

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

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

关于amazon-web-services - AWS ECS - 无法在 cloudformation 模板中指定服务名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41111335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com