Skip to content

(cdk): Support for infrastructure and code stacks as peer stacks #20327

@SamStephens

Description

@SamStephens

Describe the issue

I'm trying to use the classic pattern where you have an infrastructure stack and a code stack. I want to define these two stacks as peer stacks, and directly reference resources in the infrastructure stack from the code stack. When I started doing this, I quickly encountered a cyclic reference error that I've opened a separate bug issue for.

However I'm wanting to know whether this is a usage pattern that the CDK team support in general, and whether the CDK consider this poor practice or good practice; before I commit to it and then potentially find I'm stuck because I'm using the CDK in an unsupported fashion.

I'm not interested in using nested stacks for this. When I worked with Nested Stacks back when I was an AWS employee I found them quite clunky to work with, although this was a few years ago.

I'm currently using peer stacks, with the infrastructure stack exporting resource ARNs using CfnOutput, and the code stack then importing them using Fn.importValue. But it would be cleaner if I could safely pass the actual CDK constructs from the infrastructure stack to the code stack.

Links

https://docs.aws.amazon.com/cdk/v2/guide/stacks.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions