Deploy a scalable app from scratch in minutes with AWS App Runner
Tags: aws, awscommunity, serverless, containers
Published: 2021-06-04 13:30:55

Have you heard of [AWS App Runner](https://aws.amazon.com/apprunner/)? A few weeks ago, AWS announced a new service called AWS App Runner - the original blog post can be found [here](https://aws.amazon.com/about-aws/whats-new/2021/05/aws-announces-aws-app-runner/). AWS App Runner is a fully managed container application service that let you build, deploy and run containerized web applications and APIs in minutes. I'll show you how to do that in this blog post.

**Supported AWS Regions**

Currently, AWS App Runner is supported in the following regions: US East (N. Virginia), US East (Ohio), US West (Oregon), Europe (Ireland), and Asia Pacific (Tokyo).

**Benefits**

App Runner resources and infrastructure components are fully managed by AWS, which means you don't have to worry about scaling or infrastructure security or even be an expert in it. Resources are scaled automatically based on traffic. You stay completely focused on your application.

**Pricing**

* You are charged for the compute and memory resources used by your application.
* If you automate your deployments you will pay a set monthly fee for each application that covers all automated deployments for that month.
* If you opt to deploy from source code, you will pay a build fee for the amount of time it takes App Runner to build a container from your source code.

More information can be found on the [AWS App Runner Pricing](https://aws.amazon.com/apprunner/pricing/) page.

## AWS Console

Of course, you can also deploy the service using AWS CDK. But first, let's take a look at the AWS Console to learn about the service. Because with just a few clicks, your app is ready to go.

### Source and deployment

The first step is to choose a source for the App Runner service and how it should be deployed. 

#### Source

You can choose between an AWS Container Registry (*Amazon ECR* or *Amazon ECR Public*) and a Git repository provided by [GitHub](https://github.com/).

![AWS App Runner console - source section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5bydyij05aozcqfy6bg.png)

If you choose the Container Registry option, then you only need the Container image URI. If you want to use your Git repository on GitHub, you need to install the AWS Connector for GitHub app.

#### Deployment

Next, you need to choose whether the deployment should be automatic or manual.

![AWS App Runner console - source deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3o9p6ibez1h2n28olzn.png)

Automatic deployment is not available with every source option. If you use Amazon ECR, App Runner monitors your registry and deploys a new version of your service with each image push. If you use your Git repository from GitHub, then each push to the selected branch deploys a new version of your service.

### Configure build

*This step is only available if you have chosen "Source code repository".*

![AWS App Runner console - build section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qquqhdjvve0bqthb8v1a.png)

Currently you can choose between `Python 3` and `Node.js 12` runtime. The *"Build command"* specify the command that will be used to install the dependencies or compile the code. If you use the configuration file, you can additionally specify `pre` and `post` commands! The *"Start command"* specify the command to start a web server for your service. Also specify the port to be used by the service.

The configuration can be done manually or provided via a configuration file (`apprunner.yaml`).

```yaml
version: 1.0
runtime: nodejs12 
build:
  commands:
    pre-build:
      - npm install
    build:
      - npm run build
    post-build:
      - npm test
run: 
  command: npm start
  network:
    port: 3000
```

📚 [App Runner configuration file reference](https://docs.aws.amazon.com/apprunner/latest/dg/config-file-ref.html)

### Configure service

In this step the service is configured by assigning the resources.

#### Service settings

![AWS App Runner console - service section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2g5iplrwdqjozx61s6ft.png)

Name the service and configure the number of CPUs, as well as the required memory.

#### Auto scaling

You can use the default auto-scaling settings or configure this manually.

![AWS App Runner console - auto scaling section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwlgq656mn093f13l9is.png)

If you configure it manually, you can set the following parameters: `Concurrency`, `Minimum size (instances)` and `Maximum size (instances)`.

#### Health check

App Runner performs a TCP health check at the port that your application is listening to.

![AWS App Runner console - health check section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7bce95ha538z17gvaw8.png)

You can set the parameters `Timeout`, `Interval`, `Unhealthy threshold` and `Health threshold`.

#### Security

![AWS App Runner console - security section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ito4b437fv6nafbdxqp8.png)

In the Security section you can select an IAM role for the instance and specify whether to use an AWS-owned key or a custom AWS KMS key.

#### Tags

![AWS App Runner console - Tags section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30bafs413ljpn6y53vkw.png)

Use tags to search and filter your resources, track your AWS costs and control access permissions.

### Deployment time 🚀

In the last step you can review your configuration and then start the creation process! After a short time you will find the URL of your app in the AWS App Runner Console.

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

In addition to service metrics, event, deployment and application logs are also available in the AWS App Runner Console.

I don't think you can deploy a scalable application any easier or faster. 🚀

---

If you have any kind of feedback, suggestions or ideas - feel free to comment this post!