CDK CloudFormation Disassembler
WIP - this module is still not fully functional:
- Does not handle intrinsic functions
- Only handles the "Resources" section (parameters, outputs, mappings, conditions, ...)
- Keys in JSON blobs (such as IAM policies) are converted to camel case (instead of remain as pascal case).
- Only TypeScript is supported
Converts an AWS CloudFormation template into AWS CDK code which synthesizes the same exact template.
Why you should not use this tool?
Generally, this is not a recommended approach when using the AWS CDK, but some people may find this useful as a means to get started or migrate an existing template.
Using this method means that you will have to use the low-level resources (e.g.
s3.CfnBucket instead of
s3.Bucket). This means that you lose a substantial
portion of the value of the CDK, which abstracts away much of the boilerplate
and glue logic required to work with AWS resources.
For example, this is how you would define an S3 bucket encrypted with a KMS key with high-level resources:
new s3.Bucketthis, 'MyBucket',;
And this is how the same exact configuration will be defined using low-level resources:
new kms.CfnKeythis, 'MyBucketKeyC17130CF',;new s3.CfnBucketthis, 'MyBucketF68F3FF0',;
As you can see, there are a lot of details here that you really don't want to
care about (like the value to put under
sseAlgorithm or which actions are
required in the key policy so the key can be managed by administrators. Also,
this is actually one of the more simple examples we have in the CDK.
The AWS Construct Library includes a very large amount of "undifferentiated heavy lifting" that you can only enjoy if you use the high level resources which encapsulate all this goodness for you behind a nice clean object-oriented API.
Therefore, we encourage you to use the high-level constructs in the AWS Construct Library as much as possible. If you encounter a gap or missing capability or resource, take a look at the Escape Hatches section of the User Guide.
$ cdk-dasm < my-stack-template.json > my-stack.ts
For example, given:
The output will be:
// generated by cdk-dasm at 2019-08-07T02:52:01.561Z;;