When it comes to serverless technology, one of the most important and growing platforms is AWS (Amazon Web Services). There are a variety of open source and third-party frameworks that simplify serverless application development and deployment.
1. 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 in addition to 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 of 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 just by answering to some prompts, which is not present in the serverless framework at the time of writing this article. So Amplify slightly edges out Serverless Framework in this section.
2. Services Supported
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 and adds it to a JSON file maintained by Amplify, which is then used to deploy to AWS. We can add other services which are not directly supported by the CLI, 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 which 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 a more flexible framework in terms of services supported. Even though we can manually edit the CloudFormation in Amplify, it is not as straight forward or hassle-free as the Serverless Framework.
3. Local Testing
The first thing we can notice when starting off 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 simply not possible out of the box.
Similarly, in the case of testing my REST API endpoints locally, as of writing this article, I couldn’t find a way with Amplify. Sadly, it provides a way to mock GraphQL endpoints using a single command, which is 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 out 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.
4. 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 a while now. 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.
5. Plugin Availability
As we saw in the local testing section, Serverless Framework has a wide variety of plugins available. There are plugins which are certified and approved 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 manually add them.
Amplify has very limited 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 easy and straight forward 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 the case of 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 it’s 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 in terms of the different AWS services it provides, local testing, community support and plugin availability.
Amplify on the other hand provides an easy to develop and deploy CLI and a more complete CI/CD solution than Serverless Framework. It is still a very good option to try out for yourself. In terms of the services supported, I’m sure that they will add more and more in the coming months. Also, the community support will only increase as more developers jump into the wagon.
In my opinion, Serverless Framework is by far the best framework you can consider currently, if you are looking for a complete serverless solution for AWS.