The Easiest way to deploy services on AWS using App Runner
Tags: node, aws, serverless, beginners
Published: 2021-08-20 05:34:26

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qined63rw5ld74ub35r8.png)

**ℹ️ 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btn4pwtoo0frzlogkx3e.png)

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

![AWS App Runner with Github](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukobaae3spt1tw73merj.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gj5zzp2l6itdc01kgpbk.png)

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

![AWS App runner displaying all GitHub repositories](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajrozz5ylds8lssde9q6.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4pjcdolt9ezm6q9742kr.png)

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](https://github.com/mubbashir10/node-app) application to use with AWS App Runner**

![AWS App Runner with Sample Node JS Service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tnbj1tl8yfyf9cr422c.png)

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 ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h39f2yfgdm6y6vx1kayt.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1al6rqson0tz9go3cmrx.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpifccb1zlrc294i8sn3.png)

- **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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bck8bbxt28w30h2kric1.png)

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/](AWS IAM console) 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/](AWS Key Management Service).

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

![AWS App Runner with AWS KMS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kt4lodp54w43ajv4rd0r.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joblvxgjwrc9keuz91d8.png)

Review your configurations and click "Create & Deploy"
![Create and Deploy AWS App Runner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ba8jo8kmi1m36wu5l9a.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6puu2cclbnb6tznxfv0.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87qwod9shu49lprd82rm.png)


**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](https://aws.amazon.com/elasticbeanstalk/) or [Google's App Engine](https://cloud.google.com/appengine)

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/](https://www.linkedin.com/in/mubbashir10/) 

Twitter: [https://twitter.com/mubbashir100](https://twitter.com/mubbashir100)