【问题标题】:How to do cross stack references between aws nested stacks in cdk如何在cdk中的aws嵌套堆栈之间进行交叉堆栈引用
【发布时间】:2021-08-14 15:24:35
【问题描述】:

我的 cdk 应用程序中有两个嵌套堆栈。

export default class mainAppStack extends Stack {
 
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new NestedStackOne(this, "nested-one");
    new nestedStackTwo(this, 'nested-two);
  }
}


export class nestedStackOne extends cdk.NestedStack {
  constructor( scope: cdk.Construct, id: string, props?: cdk.NestedStackProps ) {
    super(scope, id, props);

    new new cognito.UserPool(this, `Userpool`, {
     // ...configs
    });
  });

 }


export class nestedStackTwo extends cdk.NestedStack {
  constructor( scope: cdk.Construct, id: string, props?: cdk.NestedStackProps 
  ) {
    super(scope, id, props);
    
  });

 }

我想将嵌套堆栈一中定义的用户池的 arn 传递给堆栈二。我一直在努力寻找一种方法来做到这一点。 AWS 文档没有帮助。我该怎么做呢?如何在嵌套堆栈之间引用。

【问题讨论】:

    标签: typescript amazon-web-services aws-cdk


    【解决方案1】:

    您可以使用 CfnOutput 跨堆栈导出值,并使用 core.Fn.import_value("export_name") 在另一个堆栈中使用它。这应该允许您在帐户中导入 ARN,因此嵌套结构应该无关紧要。

    文档:https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.CfnOutput.html

    【讨论】:

      猜你喜欢
      • 2018-06-21
      • 2022-01-03
      • 2021-02-18
      • 2020-04-14
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多