问题描述
我有两个 Cloudformation 文件,我想在另一个模板中引用已从一个模板创建的资源。例如:在第一个中,我创建了一个 ECS 集群。在第二个中,我想引用这个集群并在其中构建一个服务。我该怎么做?
解决方法
要做到这一点,您必须从第一个模板中 exporting stack output values。大概这将是 ECS 集群名称和/或其 arn:
import { Meta,moduleMetadata } from '@storybook/angular';
export default {
title: 'Navigation Item',component: NavigationItemComponent,decorators: [
moduleMetadata({
declarations: [NavigationItemComponent],imports: [RouterTestingModule],}),],} as Meta;
然后在第二个模板中,您将使用 ImportValue 来引用导出的输出:
MyCluster:
Type: AWS::ECS::Cluster
Properties:
#....
Outputs:
MyClusterName:
Value: !Ref MyCluster
Export:
Name: ECSClusterName