📊Tracking: migrating CloudFormation templates to the CDK
See original GitHub issueAdd your +1 👍 to help us prioritize this feature!
Overview:
We want to expand the capabilities of the CfnInclude
class from the core
package to allow retrieving and modifying the resources that form the template. Example experience:
import * as cfn_inc from '@aws-cdk/cloudformation-include';
const cfnTemplate = new cfn_inc.CfnInclude(this, 'Template', {
templateFile: 'my-template.json',
});
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
// now, we can modify the bucket, and all of those modifications will be reflected in the resulting template!
// for example, we can change its name
cfnBucket.bucketName = 'my-bucket-name';
// or, reference it in other constructs, including L2s
import * as iam from '@aws-cdk/aws-iam';
const role = new iam.Role(this, 'Role', {
assumedBy: new iam.AnyPrincipal(),
});
role.addToPolicy(new iam.PolicyStatement({
actions: ['s3:*'],
resources: [cfnBucket.attrArn],
}));
// or, reference an L2 bucket from the L1
const bucket = s3.Bucket.fromBucketName(this, 'L2Bucket', cfnBucket.ref);
Maturity: Experimental
See the AWS Construct Library Module Lifecycle doc for more information about maturity levels.
Implementation:
-
Support YAML templates in addition to JSON ones
-
Retrieving Resources by their logical ID
-
Retrieving Parameters by their logical ID
-
Retrieving Conditions by their logical ID
-
Retrieving Outputs by their logical ID
-
Support for the Properties CloudFormation resource attribute
-
Support for the Condition CloudFormation resource attribute
-
Support for the DependsOn CloudFormation resource attribute
-
Support for the CreationPolicy CloudFormation resource attribute
-
Support for the UpdatePolicy CloudFormation resource attribute
-
Support for the UpdateReplacePolicy CloudFormation resource attribute
-
Support for the DeletionPolicy CloudFormation resource attribute
-
Support for the Metadata CloudFormation resource attribute
-
Full support for all CloudFormation functions
-
Support nested Stacks
This is a 📊Tracking Issue
Issue Analytics
- State:
- Created 3 years ago
- Reactions:35
- Comments:13 (8 by maintainers)
Top GitHub Comments
Thanks for sharing the link, I wasn’t aware of that project. That’s what I was looking for 😉
The cocern I have: it will essentially mean for us to keep the CloudFormation code “forever”…or until we migrate it…and do the enhancements in CDK… which is kind of … weird…because it breaks languages “in the middle” 😃 But its a good starting point, definitely, I was not trying to narrow this down, please don’t understand me wrong.
Well, no, not exactly. That will most certainly be helpful.
But: We have a hell lot of CloudFormation already, this option would only give us the option to “keep” it and “adjust” it on the fly when using CDK.
If I want to go “all in” on CDK I would need an option to “transform” the CloudFormation code to CDK code (in whatever language).