繁体   English   中英

如何在新的 Cloudformation 模板中引用 Cloudformation 资源?

[英]How to reference Cloudformation Ressources in a new Cloudformation template?

我有两个 Cloudformation 文件,我想在另一个模板中引用已经从一个模板创建的资源。 例如:在第一个中,我创建了一个 ECS 集群。 在第二个中,我想引用这个集群并在其中构建一个服务。 我该怎么做?

为此,您必须从第一个模板中导出堆栈 output 值 大概这将是 ECS 集群名称和/或其 arn:

MyCluster:
   Type: AWS::ECS::Cluster
   Properties: 
    #....

Outputs:
  MyClusterName:
     Value: !Ref MyCluster
     Export:
        Name: ECSClusterName

然后在第二个模板中,您将使用ImportValue来引用导出的 output:

MyESSService:
   Type: AWS::ECS::Service
   Properties: 
     Cluster: !ImportValue ECSClusterName

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM