aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.72k stars 3.94k forks source link

(aws-ec2): Create non-synth VPC constructor usable in service catalog products #23198

Closed jeffb4 closed 2 years ago

jeffb4 commented 2 years ago

Describe the feature

Create a VPC constructor similar to ec2.Vpc.from_lookup that can use dynamic (or static) references without doing any synth-time lookup.

Use Case

I would like to use CDK to define a servicecatalog product that is shared with an entire ou. It therefore needs a CloudFormation render that doesn't depend on synth-time lookups. This is, generally, possible with CDK L2 constructs EXCEPT that many things depend on ec2.Vpc and providing such an object that uses CFN dynamic references (or parameter references) is non-obvious. A constructor for Vpc that lets the invoker specify vpc id, private subnets, public subnets, etc as references would enable existing L2 constructs to be used in servicecatalog.ProductStack stacks.

Proposed Solution

ec2.Vpc.from_references(stack, vpc_id="vpc-foo", public_subnets=["foo","bar","baz"])

Other Information

No response

Acknowledgements

CDK version used

2.53.0

Environment details (OS name and version, etc.)

Linux docker-desktop 5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

jeffb4 commented 2 years ago

Uh, you know, looking at the ec2.Vpc. fromVpcAttributes source code, that's the exact intent of that constructor so I'll close this. I guess a blurb in the docs about the "right" way to use that constructor might have prevented this question, but who knows. Sorry for the noise!

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.