amazon-web-services - 如何在新的 Cloudformation 模板中引用 Cloudformation 资源?
问题描述
我有两个 Cloudformation 文件,我想在另一个模板中引用已经从一个模板创建的资源。例如:在第一个中,我创建了一个 ECS 集群。在第二个中,我想引用这个集群并在其中构建一个服务。我该怎么做?
解决方案
为此,您必须从第一个模板中导出堆栈输出值。大概这将是 ECS 集群名称和/或其 arn:
MyCluster:
Type: AWS::ECS::Cluster
Properties:
#....
Outputs:
MyClusterName:
Value: !Ref MyCluster
Export:
Name: ECSClusterName
然后在第二个模板中,您将使用ImportValue来引用导出的输出:
MyESSService:
Type: AWS::ECS::Service
Properties:
Cluster: !ImportValue ECSClusterName
推荐阅读
- javascript - 通过 .map 问题转换对象数组
- sql - SQL Server 2008 R2:查找两列之间的链接和链
- javascript - webpack css-loader 解析失败
- c++ - c++ 基于模板字符串字面量返回的函数指针
- java - SOCKET TCP android java to java -> 客户端在 out.println(message) 上发送错误消息
- r - 计算以相同的第一位数字,然后是第二位数字等开头的数字的出现次数
- javascript - 在平行表中对齐单元格高度
- php - 需要修复 mysqli_result 代码
- python - 单击,双击和鼠标移动
- javascript - 如何重新渲染谷歌地图以对状态变化做出反应?