InApp   /   Our Leaders   /  

Comparing AWS Framework: Amplify vs Serverless

Comparing AWS Framework: Amplify vs Serverless

One of the most important and growing platforms is AWS (Amazon Web Services) when it comes to serverless technology.  There is a variety of open-source and third-party frameworks that simplify serverless application development and deployment.

My journey in the serverless computing space started with the search for a perfect framework that supports JavaScript and would make me accomplish my requirements with ease. Two of the best ones that I had to pick between were the Serverless Framework (a third-party open-source framework supporting other cloud platforms) and the Amplify Framework (developed by AWS). I tried both of them. The remaining part of this article is my findings, which would help you decide on the framework you should choose for your project. I’ll split my views into Ease of Development, Services Supported, Local Development Testing, Documentation and Community Support, Plugin Availability, and CI/CD and compare the frameworks within each section.

Amplify vs Serverless: Ease of Development

Amplify vs Serverless: Ease of Development

Both frameworks provide CLI-based development. In Serverless Framework, you can start the development by using one of the templates provided for the language you use. In my case, since I use JavaScript, I can use the command given below:

SLS create –template aws-nodejs

To deploy the application to AWS, we only need to use a single command given below:

SLS deploy

Amplify provides UI Components for front-end frameworks such as React and creating and managing the back end. We can use the command below to create an Amplify application:

amplify init

To add/remove a specific service, we can use the following command:

amplify <category> add/remove

Here category is one of the different ones supported by Amplify, and each comprises different AWS Services.

To deploy an amplify application, we can use the following command:

amplify push

As you can see, both frameworks provide CLI commands to easily develop and deploy your serverless application in less than 3 commands. But Amplify provides a CLI command to easily create different AWS services by answering some prompts, which is not present in the serverless framework when writing this article. So Amplify slightly edges out Serverless Framework in this area.

Services Supported by Amplify

Amplify currently supports the following categories:

  1. auth (Amazon Cognito), 
  2. storage (Amazon S3 & Amazon DynamoDB)
  3. function (AWS Lambda)
  4. API (AWS AppSync & Amazon API Gateway)
  5. analytics (Amazon Pinpoint)
  6. hosting (Amazon S3 and Amazon CloudFront distribution)
  7. notifications (Amazon Pinpoint)
  8. interactions (Amazon Lex)
  9. predictions (Amazon Rekognition, Amazon Textract, Amazon Translate, Amazon Polly, Amazon Transcribe, Amazon Comprehend, and Amazon SageMaker)

These are the services supported by Amplify out of the box. When we add a category using the command mentioned in the previous section, it creates the necessary CloudFormation syntax for the resource. It adds it to a JSON file maintained by Amplify, which is then deployed to AWS. We can add other services that the CLI does not directly support by manually editing this CloudFormation file. But a small issue I found is that the CLI overwrites the same file when we add/remove a category. This can undo the changes that we made to the file.

Serverless Framework, on the other hand, has no pre-defined set of supported services. Since it uses an abstraction of AWS CloudFormation syntax, we can add any service as a resource using the same. It uses a serverless.yml file that contains all the infrastructure resources defined. Once we deploy the application, it generates AWS CloudFormation, which creates a CloudFormation stack in AWS.

So, in my opinion, the Serverless Framework is more flexible in terms of the services supported. Even though we can manually edit the CloudFormation in Amplify, it is not as straightforward or hassle-free as the Serverless Framework.

Amplify vs Serverless: Local Testing

The first thing we can notice when starting with Amplify is that it promotes GraphQL more than REST. For example, I want to use the AWS ElasticSearch service for my project. But it is only directly supported by GraphQL. I want to use REST API endpoints with AWS ElasticSearch service, which is not possible out of the box.

Similarly, in the case of testing my REST API endpoints locally, I couldn’t find a way with Amplify at the time of writing this article. Sadly, it provides a way to mock GraphQL endpoints using a single command, not what I want.

Serverless Framework has a plugin that supports offline testing of the REST API endpoints, and it also has a plugin for creating a local instance of DynamoDB. It even has a plugin to test the DynamoDB streams locally, which I’m using in my project.

As per my requirement, the Serverless Framework provides far better local testing abilities than Amplify.

Amplify vs Serverless: Documentation and Community Support

Both frameworks provide excellent documentation. But I found more examples of different services for the Serverless Framework. I think this is because the Serverless Framework has been here for quite some time. So it has a comparatively large community of users than Amplify.

I encountered several different issues with both of the frameworks. In such cases, the Serverless Framework community was more helpful in resolving them. Since Amplify is quite new, most of the issues encountered were bugs that weren’t resolved. But, there were some workarounds for the same, provided by the community, which were useful.

In this section also, Serverless Framework continues to shine as compared to Amplify.

Amplify vs Serverless: Plugin Availability

As we saw in the local testing section, Serverless Framework has a wide variety of plugins available. There are certified and approved plugins by Serverless Framework Team, and there are also community-built ones. These plugins make it easy to add new functionality to the framework without having to add them manually.

Amplify has a minimal number of plugins as compared to Serverless Framework, but the Amplify CLI provides a way to create our own plugins using the command below:

amplify plugin init or amplify plugin new

In terms of plugins, the Serverless Framework is again far ahead of Amplify.

Amplify vs Serverless: CI/CD

Amplify provides a way to implement the CI/CD of your full-stack application through the Amplify Console. We can associate our Amplify application repository with Amplify Console. It is pretty straightforward to set up. But in my experience, CI/CD was a hit or a miss. Some of the time, I came across some weird issues. But when it works, everything is flawless.

In Serverless Framework, we can implement CI/CD for the back end using AWS CodeBuild, CodeDeploy, and CodePipeline. We can add the necessary CloudFormation to the serverless.yml to create the deployment pipeline in AWS.

Even though Amplify has its own issues, it provides CI/CD for the full stack of our application, which is not the case with the Serverless Framework. So I feel it provides a more complete CI/CD solution than the one offered by Serverless Framework.

Conclusion

Serverless Framework is a more established framework than Amplify. It has the upper hand regarding the different AWS services it provides, local testing, community support, and plugin availability.

On the other hand, Amplify provides an easy-to-develop and deploy CLI and a more complete CI/CD solution that Serverless Framework. It is still an excellent option to try out. I’m sure that they will add more in the coming months in terms of the services supported. Also, community support will only increase as more developers jump on the bandwagon.

In my opinion, Serverless Framework is by far the best framework you can consider currently if you are looking for a completely serverless solution for AWS.