banner.jpg
AWS Amplify as a Serverless Solution

IntroductionHow much time do you spend on your server configuration? Amplify connects a backend to a web or mobile application in a few minutes, deploys static web applications, and manages the content or users in the AWS console easily. This blog explores the philosophy behind AWS Amplify, the relationship with serverless, the setup, features, and the multiple uses.

What is Amplify?
Amplify is a set of open-source tools and services that can work together seamlessly or on their own to build full-stack, front-end web, and mobile applications. The cost of Amplify is only for the resources used, alarms can be added to know when a particular cost threshold is crossed.
ref-2

Amplify has two main components.

  • An open-source framework that contains a set of libraries, UI components
  • A command-line interface (CLI) to build an app backend.

The CLI which is probably the component that a developer is going to use more frequently. Amplify has an admin UI that simplifies the backend setup with a visual point-and-click experience that works seamlessly with the Amplify CLI. The admin UI also includes functionality for managing app content and users.

So, Amplify exists based on the concept of serverless.

Serverless

Serverless is one of those concepts that has been gaining popularity in the last decade.

It has been searched by more people around the world in the last five years, and the reason for that is because it is a model that is sometimes misunderstood. On the web, there is a lot of information about serverless. It is most frequently defined as a model where there are no servers, and the application's code runs like magic which is not technically correct.

Serverless is a cloud computing execution model in which the cloud provider allocates machine resources on-demand, taking care of the servers on behalf of their customers.

Developers focus only on the code, and they do not need to manage the server tasks such as capacity planning, configuration, management, maintenance, operation, or scaling. AWS has products such as Lambda, DynamoDB, S3, API Gateway, all of them could be used to create systems based on the serverless architecture.

Amplify setup

The first step to use Amplify is to have an AWS account. Then, install the Amplify CLI via NPM, remember that NodeJS needs to be installed.

The CLI provides a way to interact with the AWS APIs. These are used to create the backend for the application. The following steps allow to set up and use the Amplify environment

  • Run the Amplify configure command to set up the region.
  • Configure IAM attributes to generate an access key id, and a secret access key to connect the AWS account with the local Amplify instance.
  • Execute the command Amplify init inside the folder application, which based on questions, creates the configuration files depending on the technology.
  • Add resources to the application, such as API with GraphQL API or REST API configuration.
  • Execute the command Amplify push to create the backend resources that the application will use.
  • Also, the Amplify console API will open a browser window with the Amplify Web UI to manage the AWS resources in the AWS console.

Commands like Amplify status will list all the Amplify resources data configured in the project to know if it is needed to run the command Amplify push again to sync the AWS resources. Also, this command will allow team members to keep in sync with new backend resources added to the project.

Amplify features

Cloudformation

Amplify uses the CloudFormation AWS tool to create infrastructure as code, which could be described as a template in YAML or JSON files. The advantages of these approaches are:

  • All the backend resources are represented in code to store them in a Git repository and keep track of the changes made to them.
  • Amplify can see something changed and update the resources once the Amplify push command is run. In this way, the members of the team can pull those changes, and everything is synchronized.

MultiplatformThe CLI is supported on macOS, Linux, and Windows, and the Amplify Framework is supported on React, Vue js, plain Javascript, iOS, Android, and Flutter.

HostingAWS Amplify offers a fully managed service for deploying and hosting static or single-page web applications, and it is pretty straightforward to set up too. It can be set up, so that when the code is merged on the Git repository, the website will be also updated. The Git platforms supported are Github, BitBucket, Gitlab, and AWS CodeCommit.

Ampify uses

The Amplify philosophy is “do more with less”, but to understand how Amplify can scale and how it works among teams, it is necessary to know how Amplify modules work under the hood. Some of them use Amazon Cognito for Authentication, S3 for storage, Lambda for functions, API Gateway, and App Sync for the API section among others.

Amplify init command

Creates an Amplify directory inside of the root application path where the backend resources will live.

Amplify add API command

Adds a graphQL API using AWS Appsync or rest APIs backed by API Gateway, then the CLI will update the cloud formation - template.json file, and it will add the resources to it. This is the way that CloudFormation works.

Amplify add auth command

Automates the access control policies for the resources protecting the data in the APIs using AWS Cognito. Cognito is a robust user directory service that handles user registration, authentication, account recovery, and other operations. It can be integrated with Facebook and Google. Besides, Amplify has prebuilt UI elements such as user registration, login, and password recovery.

Amplify add storage

Depending on the content to store. CLI will use S3 to save files or it will create a NoSQL database using DynamoDB. The storage is backed by Amazon S3, which is a service to save data on public or private buckets.

Is Amplify useful for me?
It depends on the technology of your project. Amplify makes it easier to deploy and maintain the applications’ backend. IT provides powerful features to focus on the application logic and leave to Amplify the management and deploying tasks.
ref-7

®CBQA Solutions
logo-cbqa-cloud

Locations

USA

Mexico

Colombia

Contact

+01 (925) 951-8681

+52 (477) 104-3350

info@cbqasolutions.com