I have this template that works as expected. Is there any way to convert it as cdk python code?
https://github.com/shantanuo/cloudformation/blob/master/updated/api-to-sns-cf%20(1).yml
I have this template that works as expected. Is there any way to convert it as cdk python code?
https://github.com/shantanuo/cloudformation/blob/master/updated/api-to-sns-cf%20(1).yml
There is nothing wrong with using low-level resources, as it's a useful building block. Yes, there are high level constructs, but like everything else in software, occasionally you have to dig deeper. It's a shame that the attitude like this has continued, because for some of us, that have spent years building out a nice collection of CloudFormation templates, are discouraged from using CDK.
Yes, there are some issues with this, mostly because of some poor architecture decisions and a desire to focus on the new instead of building up layers of functionality, but it's possible and you shouldn't be dissuaded in converting your templates to low-level constructs, and then refactoring into higher-level ones as your use case requires.
That said, I would NOT use any kind of automatic tools to do this conversion. You won't actually understand what's going on, and you'll more than likely have issues that you won't know how to handle. Dig in, convert line-by-line, and then enjoy the results.
You can't convert a CloudFormation template to CDK code. It doesn't really make sense to do it, either. Kind of like asking to convert assembly, or C, to Python.
In Troposphere's case it makes sense, because Troposphere has a 1:1 relationship to CloudFormation. The CDK is supposed to be higher level, much like Python's relation with Assembly or C. The CDK does have CfnResource classes, which do translate directly to CloudFormation, but that's just the necessary underlying layer, it's not how the CDK is supposed to be used. If you want to go that way, you'd be better off with Troposphere.
It might sound like it would make sense to be able to do it during a transition period, but in my opinion it's more trouble than it's worth. Anyway, there's nothing that does it at this time.
Edit: For Typescript, there's cdk-dasm. It's Typescript only and it converts CloudFormation to Cfn resources. Quoting from that page:
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.