-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-ec2): L1 VPC to L2 VPC transformation #14809
Comments
Thanks for opening the issue @brockuniera. We are thinking about this. Related: #14795 |
This is part 1 of adding support from converting L1 resources to L2 without making them immutable in the process. Next phase after this will be adding support for `Bucket.fromCfnBucket()` (which will use the method from KMS defined here). Related issues: #9719 #14795 #14809 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This is part 1 of adding support from converting L1 resources to L2 without making them immutable in the process. Next phase after this will be adding support for `Bucket.fromCfnBucket()` (which will use the method from KMS defined here). Related issues: aws#9719 aws#14795 aws#14809 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I would love to see this - I have my vpc defined with a CfnVpc to get a little more control over the creation of subnets etc, and I need to use this vpc in the rest of my stack. At the moment I am doing a lookup based on tags which breaks if the stacks do not run in the correct order. |
I'm dealing with a similar scenario as mattsoftware and would find this extremely useful as well. |
Same here @moosius ! This CDK seems much more complicated than it needs to be. |
This would be so useful! We cannot create our own VPC code because we have to connect to a corporate network infastructure through pre-provisioned TGWs, so we're getting pre-baked CFN templates that we have to import. Not having the L2 object without using lookups is quite a pain. |
+1 |
BTW, I wrote a Tweet about this topic, but let me repeat it here. If you have a template with a VPC, and you want to turn it into an Example code in TypeScript, but something very similar should work for other languages too: const cfnInclude = new cfn_inc.CfnInclude(this, 'VpcTemplate’,
templateFile: ‘vpc-template.yaml',
});
const cfnVpc = cfnInclude.getResource('VPC') as ec2.CfnVPC;
const privateSubnet1 = cfnInclude.getResource('PrivateSubnet1') as ec2.CfnSubnet;
const privateSubnet2 = cfnInclude.getResource('PrivateSubnet2') as ec2.CfnSubnet;
const cfnRouteTable1 = cfnInclude.getResource('PrivateRouteTable1') as ec2.CfnRouteTable;
const cfnRouteTable2 = cfnInclude.getResource('PrivateRouteTable2') as ec2.CfnRouteTable;
const vpc = ec2.Vpc.fromVpcAttributes(this, ‘ImportedVpc', {
vpcId: cfnVpc.ref,
availabilityZones: cdk.Fn.getAzs(),
privateSubnetIds: [privateSubnetl.ref, privateSubnet2.ref],
privateSubnetRouteTableIds: [cfnRouteTablel.ref, cfnRouteTable2.ref],
}); Of course, adjust to the exact contents of your template as needed! |
@skinny85 Your comment is about an CF Template and this is asking for I don't see any way to get the data needed to get the I am hitting a wall with this and I really need to be able to convert a |
It shouldn't matter where the |
Pardon my ignorance but this seems to work mostly due to the const privateSubnet1 = cfnInclude.getResource('PrivateSubnet1') as ec2.CfnSubnet;
const privateSubnet2 = cfnInclude.getResource('PrivateSubnet2') as ec2.CfnSubnet;
const cfnRouteTable1 = cfnInclude.getResource('PrivateRouteTable1') as ec2.CfnRouteTable;
const cfnRouteTable2 = cfnInclude.getResource('PrivateRouteTable2') as ec2.CfnRouteTable; I don't see any way to get these values from the |
What the CDK Construct Library calls the In order to instantiate a |
I would like to add that it comes in handy, when used with copilot CLI. It started to support transforming resources through overrides: |
Static method on
Vpc
akin to.fromLookup
with signature.fromCfnVpc(cfnvpc: CfnVpc): IVpc
that performs a hopefully simple transform on aCfnVpc
to return aIVpc
.Use Case
More convenient and supported method for mixing
CfnInclude
'd CloudFormation templates with CDK constructs.Proposed Solution
Implement the described static method.
Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: