[英]How to dynamically name an ECS cluster with cloudformation?
使用硬编码名称创建群集MyCluster
很容易:
"MyCluster": {
"Type": "AWS::ECS::Cluster"
}
但是,我想要一个动态名称,但也要引用命名资源。 像这样的集群名称将是堆栈名称:
"NamedReferenceButNotClusterName": {
"Type": "AWS::ECS::Cluster",
"Properties": {
"Name": {"Ref": "AWS::StackName"} <-- Name property isnt allowed
}
},
"ecsService": {
"Type": "AWS::ECS::Service",
"DependsOn": [
{"Ref": "NamedReferenceButNotClusterName"} <-- not sure if I can even do this
],
"Properties": {
"Cluster": {
"Ref": "NamedReferenceButNotClusterName" <-- I really want this part
},
"DesiredCount": 2,
"TaskDefinition": {
"Ref": "EcsTask"
}
}
}
有什么办法吗?
AWS云形成是不可能的。
"MyCluster": { "Type": "AWS::ECS::Cluster" }
以上cloudformation脚本将生成名称格式为<StackName>-MyCluster-<RandomSequence>
的ECS集群。 堆栈名称在执行cloudformation脚本时作为输入提供。 随机序列是由云形成生成的,不能确定。
此时,最好使用aws cli或使用aws sdk的小程序来创建具有所需命名约定的集群。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.