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.
Ease of Development
SLS create –template aws-nodejs
To deploy the application to AWS, we only need to use a single command given below:
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:
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:
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.
- Amplify currently supports the following categories:
- auth (Amazon Cognito),
- storage (Amazon S3 & Amazon DynamoDB)
- function (AWS Lambda)
- API (AWS AppSync & Amazon API Gateway)
- analytics (Amazon Pinpoint)
- hosting (Amazon S3 and Amazon CloudFront distribution)
- notifications (Amazon Pinpoint)
- interactions (Amazon Lex)
- 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 which 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.
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.
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.
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 provides a way to implement 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.
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 than 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.