DEV Community

Mubbashir Mustafa
Mubbashir Mustafa

Posted on • Updated on

The Easiest way to deploy services on AWS using App Runner

AWS App Runner is newer service introduced by AWS. Using AWS App Runner you can run your production grade containerized services within few mins.

From AWS Console, navigate to AWS App Runner and click on "Create an App Runner Service".

AWS App Runner - The easiest way to run your containers on production

ℹī¸ You can either link your GitHub repository (and build your app) or use ECR (private or public images) with AWS App Runner. For this tutorial, however, we are going to use Github.

Select "Source code repository", and then click on "Add new".

Run production containers on AWS App Runner

It will open up a new tab and ask for GitHub authorization, click on "Authorize AWS Connector for Github"

AWS App Runner with Github

Give a name to your AWS-Github connection and then click on "Install another". It will take you to GitHub and display your account/organization. Select the one where your repo (that you want to use with AWS App Runner) is hosted.

AWS App runner connects with github

Select "All Repositories (or you can choose a specific one)" and click "Install".

AWS App runner displaying all GitHub repositories

After the installation is finished, it will redirect you back to AWS. You will notice that now the dropdown has the connector name selected; click "Next"

AWS and Github connection

Select the connection you just created. Then select the repository where your app's source code (the one you want to deploy on AWS App Runner) is located. Select the branch from the repository you want to use. In the deployment settings, select "Automatic" and click "Next"

ℹī¸ If you don't have an existing app, you can clone this sample Node JS application to use with AWS App Runner

AWS App Runner with Sample Node JS Service

Choose "Configure all settings here", choose "Node.js 12" as the runtime, provide the installation command (usually npm i or yarn), provide the command to start your application (e.g yarn start) and finally enter in the port on which your app listens.

Run Nodejs app on AWS App Runner

Give any name to your backend service, select vCPU and memory as per the need (expected load/traffic), and enter environment variables (if needed) as key/value pairs

Backend services on AWS App Runner

In the "Auto-scaling" settings, you can use the default one or if you need to adjust them then create a "Custom configuration"

AWS App Runner auto-scaling options

  • Concurrency:
    Max. number of concurrent requests/connections after which a new instance will be launched

  • Minimum size:
    It's the minimum number of instances that will always be running regardless of load

  • Maximum Size:
    Maximum number of instances you want AWS App runner to launch when the load increases (in this case more than 100 concurrent requests/connections)

The health check is a mechanism to know whether the service is performing and stable or not. You can leave the default settings or configure them as needed

AWS App Runner Health Checks

By default, the Unhealthy threshold is set to 5. This essentially means that whenever 5 health check requests from the load balancer to an instance fails, it will consider it unhealthy and try to replace it.

Next, you can create a custom IAM role from the https://aws.amazon.com/iam/ that will give permissions to your container to communicate with other AWS services or you can leave it. To encrypt the stored image (if you chose ECR image ) or stored source code bundle (if you chose GitHub, earlier) you can use AWS-owned encryption key or customer-managed key CMK (can be created from https://aws.amazon.com/kms/.

By default, if you don't provide one, an AWS-owned encryption key is used.

AWS App Runner with AWS KMS

Tags are optional key/value pairs to help you identify and group your AWS resources. Add tags if needed and then click "Next"
AWS App Runner Tags

Review your configurations and click "Create & Deploy"
Create and Deploy AWS App Runner

It will take some time to build your app, once the status changes from "Operation in progress" to "Completed", your changes are deployed

Once the service has deployed successfully, get the default domain link and see it in action

AWS App Runner with automatic builds

Let's make some changes to your code and push it - you will notice that the build process triggers automatically and deploys the new version

CI/CD in AWS App Runner

Notes:
AWS App Runner is an easy-to-use service. You can get started with it without any prior AWS knowledge. It can help you deploy your services (containerized, nodejs, or python) easily. Not exactly, but it can be considered as a toned-down version of AWS Elastic Beanstalk or Google's App Engine

If you want to deploy containerized applications/services on AWS App Runner [then read] this(https://dev.to/mubbashir10/deploy-containerized-services-on-aws-app-runner-2897)


Let's connect:

Linkedin: https://www.linkedin.com/in/mubbashir10/

Twitter: https://twitter.com/mubbashir100

Top comments (0)