![Amplify vs. CDK in 2024](/_next/image?url=https%3A%2F%2Fassets.community.aws%2Fa%2F2apMtZMSV4OFDQKtgX3jg2Ah0cz.png%3FimgSize%3D1200x630&w=3840&q=75)
Amplify vs. CDK in 2024
AWS Amplify vs. AWS CDK What is the most powerful AWS IaC in 2024?
Published Jan 11, 2024
First things first acronyms are always a tough start to a post so lets clear up a few of them.
AWS’s description for the AWS CDK
The AWS Cloud Development Kit (AWS CDK) is an open source software development framework to define your cloud application resources using familiar programming languages.https://aws.amazon.com/cdk/
AWS’s description for AWS Amplify
AWS Amplify is a set of products and tools that enables mobile and front-end web developers to build and deploy secure, scalable full stack applications, powered by AWS. With Amplify, you can configure app backends in minutes, connect them to your app in just a few lines of code, and deploy static web apps in three steps. Get to market faster with AWS Amplify.https://aws.amazon.com/amplify/
At first glance it would seems like these two products are not related at all. However both are tools that you can use to build cloud applications while maintaining the resource definitions in your code, what we call Infrastructure as Code (IaC). There are several tools that help with IaC across many cloud platforms, but especially with AWS and we will cover those in further details.
The AWS CDK was released at AWS New Your Summit 2019 which you can watch Martin Beeby talk about in the below YouTube video.
The most amazing part about the CDK is that you can write your definitions in the language of your choice (well of the supported choices). At the time of this article the supported languages are TypeScript, JavaScript, Python, Java, and C#.
Developers can use one of the supported programming languages to define reusable cloud components known as Constructs. You compose these together into Stacks and Apps.
Below you can see it is very readable in your IDE
To get started all you have to do is install the AWS CDK globally with npm like below.
Once you do this I would suggest reading through the getting started guide that AWS provides.
AWS Amplify was released in 2018, probably the best example of the release I could find was from Nader Dabit, Senior Developer Advocate at Amazon Web Services.
I had an opportunity to sit down with the AWS Amplify team on Code with CodingCat.dev showing off the new AWS Amplify UI, I would highly recommend giving this a watch to see how to utilize the new components.
When you start using AWS Amplify you will notice that it is geared more towards the entire platform to be supported. Making it very simple for a Web or Mobile developer to get started very easy. The configurations for your backend are done mainly through the CLI and some configurations on your GraphQL (or REST) definitions.
What is similar between AWS CDK and AWS Amplify is that they both create CloudFormation files and deploy using AWS CloudFormation. This is the key when comparing them as Infrastructure as Code tools. However where the difference lies is the focus for each tool.
AWS Amplify is all about mobile and web apps and has a very specific setup to get you writing your web or mobile application fast! It does this by using 3 components libraries, UI components, and a CLI toolchain. What Amplify does is allow for creating the below services very easily.
- User registration & authentication
- Offline synchronization & conflict resolution
- Access data from multiple data sources
- Manage user content
- Collect analytics data for your app
- AI/ML including text translations
- Create conversational chatbots
- Send targeted communications
- Manage messaging & subscriptions
Much of this is done via the CLI and one comment that I hear a lot is that there is too much hidden “magic” that is happening when using the CLI to create all of these configurations.
If you know for a fact that your next application is going to need tools outside of the ones listed above I would look to leverage another IaC like AWS CDK. The biggest thing is going to be developer happiness and testability within your application. If you spend all day fighting with customized CloudFormation written in customized JSON resources in AWS Amplify your developers are probably going to start to dislike the maintenance of the entire Amplify solution.
The wonderful part about both AWS Amplify and AWS CDK is that they are both powered by CloudFormation, so you get all the benefits of CloudFormation, including repeatable deployment, easy rollback, and drift detection.
Both tools also allow you to develop infrastructure and runtime code together.
One of the biggest things that I believe AWS CDK has that Amplify does not are the idea of Constructs. Constructs are vetted architecture patterns, available as an open-source extension of the AWS Cloud Development Kit (CDK), that can be easily assembled declaratively to create a production-ready workload. You can find an entire AWS Solutions Constructs repository.
So a great example of using the CDK over Amplify would be if you are developing an IoT solution. This isn’t a great fit for Amplify but below are all the Constructs that will get you started quickly.There is a great list of features still coming on the AWS CDK roadmap.
I know you read through all of the above and you did your best to already formulate an opinion and that was my goal. Don’t let the tools stop you from creating exactly what you need, make sure you list out what you are trying to accomplish and then you can easily determine what IaC will work best for you. I believe as long as you have your Infrastructure in some type of code and it allows you to repeat your work easily, that is going to be the best solution for you.
One of the biggest and most exciting updates is the new Gen2 feature which lets you stay in code even more while using Amplify. I am just now starting to test this out but I think the future is bright!!
WHY NOT BOTH??
Better yet if you are looking to start with AWS Amplify and then continue building on top of this base you absolutely can! Checkout Nader Dabit’s Mixing Amplify with CDK - Building an Authenticated GraphQL API with TypeScript on AWS