Reference cross-instance StackSet outputs

0

Let's assume two StackSets, "BucketStack" and "LambdaStack".

  • BucketStack get's deployed to account A, region us-west-1, we have now instance Bucket1 with output bucketArn
  • LambdaStack get's deployed to account A, region us-west-1, we have now instance Lambda1
  • Withing Lambda1 I want to access bucketArn in instance Bucket1

Is there any way to achieve that? Best case would be a direct CDK way.

1개 답변
1
수락된 답변

Hi Jonas,

Yes, you can export the output from one stack and import its value into another stack in Cloudformation and CDK.

Since you are using CDK, you can export a resource's output by creating a cfnOutput with an exportName property.
You can then use Fn.ImportValue to import the exported value to another stack.

I think this blog [1] outlines exactly the use case that you are looking for.

Also, please make a note of the following, in case you plan to have multiple stack instances exporting the output with the same export name bucketArn [2]:

For each AWS account, Export names must be unique within a region.

References:
[1] https://bobbyhadz.com/blog/import-value-aws-cdk-cross-stack
[2] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-crossstackref.html

Regards,
Atul

profile picture
답변함 7달 전
profile pictureAWS
전문가
검토됨 7달 전
  • Thanks a lot, especially for the first reference link. I probably searched too much just for StackSets. Do you know if there is an more implicit way in AWS CDK? With usual Stacks and Nested Stacks and so on you can use code references in the other stacks and CDK makes all of the output/import stuff.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠