CDK vs CloudFormation: is the latter somehow deprecated, in favour of the the newer? Or do they cover different use cases?

1

I've come across different tools explaining how to migrate from a CloudFormation template to CDK - I seem to understand CDK comes with more features, hence the question: when starting from scratch, is it always worth using CDK? Or are the 2 tools covering different use-cases? If someone needs to start now, is it still worth using CloudFormation, or could a newbie go straight to CDK?

Thanks

질문됨 2년 전1697회 조회
2개 답변
2

If anything, CDK is making CloudFormation even more so required: CDK generates the templates that are then used to deploy your resources in AWS via CloudFormation, not instead of using CloudFormation.

Now, is it always worth using it ? I do not think so at all. CDK fits some needs, but why spend the time and effort into writing a script in CDK that should really just be a simpler template?

Plus, again that's just my opinion, using CDK also takes away some of the key functionalities that make CFN so great. You might end up feeling like you have to "hardcode" values into your templates, which could just have been a parameter, a mapping, or have in code conditions that will only work for a narrow case but a CFN Conditon would have done just fine.

Seen plenty of CDK generated stuff where the template becomes un-reusable in different accounts, regions, partitions and so on. And that's a damn shame considering that CFN is here to allow taking one template, and it will work, anywhere in AWS.

I much prefer Troposphere to CDK too. At least in Python. Troposphere in version 4+ generates his code from the AWS CloudFormation specifications, and the property names are a 1:1 match to the documentation, whereas in CDK so many resources have their properties renamed.

As for CDK doing lookup of existing resources, nothing you could not do with the APIs anyways, and again, often, that's a hardcode.

profile picture
답변함 2년 전
  • Good answer! In my opinion, Terraform and CloudFormation are most easy and beautiful!!!

1

It depends on your preference. If you are comfortable writing Infrastructure as Code in YAML (or JSON), then you should use Cloudformation.

If you are comfortable writing code in a programming language like Java, Python, Javascript, Go etc. then CDK is the tool you may want to use. You should take a look at the CDK FAQs to better understand all the capabilities that CDK offers - https://aws.amazon.com/cdk/faqs

If my answer resolves your question, please upvote and accept my answer. Thanks

profile pictureAWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠