AWS App Runner

Learn via video courses
Topics Covered

Overview

AWS App Runner is an AWS service that provides us with the facility of deploying a fully managed containerized application. The customer's entire focus is maintained on the application rather than the infrastructure setup. AWS, behind the scenes, provides the setup for building, deploying, and running applications in containers.

Introduction to AWS App Runner and Its Working.

AWS App Runner Logo

AWS App Runner deploys containerized web applications automatically and scales accordingly as traffic. It provides a simple, fast, and cost-effective way to deploy the application from source code or a container image.

The developers can optimize the application code instead of configuring the infrastructural requirements. AWS App Runner takes care of the entire process of building, deploying/launching, monitoring, and scaling application servers.

AWS App Runner connects directly to the source code or image repository. It provides an automatic integration and delivery pipeline, which AWS fully manages.

connecting aws app runner

Working of AWS App Runner

AWS App Runner is a container application service fully managed by AWS. We can easily build, deploy, and run a web application without any previous infrastructure or container experience.

working of aws app runner

Let's understand the working of AWS App Runner by breaking the entire process into small steps.

  • Add a Source - The App Runner connects with the source code or container image, whichever needs to be containerized. The source code repository or the container image location needs to add by us.
  • Configure Build and Service Settings - We need to select the deployment settings. Other configurations like storage, CPU, and health check options also need to be mentioned for the container to run using the AWS App Runner.
  • Review and Create - The settings and infrastructure configuration are reviewed to ensure everything is in place as needed. After review, the application is deployed using the AWS App Runner.
  • Secure URL - Once the application (based on the source code/image) is deployed successfully, we receive a secure URL. This URL is used to connect to the containerized application.

AWS App Runner Architecture

The AWS App Runner Architecture comprises three major components the source code repository/image, the AWS App Runner Service, and the containers on which our applications run.

Let's discuss the complete architecture and how they work together.

  • AWS App Runner creates the service on the AWS cloud using the source code or image provided by the developer. We have to call just one App Runner action to create the service.
  • Once the service is created, AWS App Runner uses the source image repository, where we provided the code and instructions for building and running the web service/application.
  • AWS App Runner uses a specific runtime environment. Runtime Environment can be considered as a small form of an operating system that contains all the functionalities required for running an application.
  • App Runner supports different programming languages, and this runtime environment helps to execute the application code.

overview of app runner service architecture

The above diagram shows the overview of App Runner service architecture. Here we see two App Runner services.

  • App Runner Service 1 is using source code from GitHub to deploy the services.
  • App Runner Service 2 is using the source image from Amazon ECR to deploy the services.

AWS App Runner takes the source code from GitHub or the source image from Amazon ECR respectively and runs the application.

AWS App Runner Concepts

Let's discuss some concepts associated with the AWS App Runner service.

App Runner Service

App Runner Service is the resource that AWS App runner uses to launch applications. In other words, when you launch your application via AWS App runner, the running application is referred to as the AWS App Runner service.

Source Type

You can run your application using the AWS App runner service by providing the source code or image. Source type represents the type of source repository, and it can be a code or image.

Repository Provider

There are multiple repository services available that contain your code or images. These services, which provide the facility to store your code/images, are known as repository providers. For example, we have Github, Amazon ECR, etc.

App Runner Connection

To run the application, AWS App Runner needs to connect with the repository which contains the source code or image. This connection is referred to as the App Runner Connection.

Runtime

The base image for deploying the source code is in different languages. So, AWS App Runner provides different programming platforms, and they are managed by different applicable versions of runtime, like Nodejs 12, Nodejs14, Python 3, PHP 8.1, etc.

Deployment

We deploy the source code from the repository, and it builds a version of the source code on deployment. The first deployment occurs when we create the AWS App Runner service. After that, the deployment can be done in two ways, either manual or automatic, according to the changes made in the source code or configuration files.

Custom Domain

AWS App Runner allows us to customize the domain to access the web service. It also provides a default App Runner subdomain to access the web service.

Maintenance

AWS fully manages AWS App Runner. If any activity performs on the infrastructure of the App Runner service, then the App Runner Service goes in a maintenance state. When any maintenance happens, the service status changes to the OPERATION_IN_PROGRESS for a few minutes. During the maintenance period, actions like deployment, configuration update, pause/resume, or deletion of the service are blocked. After a few minutes, when the maintenance completes its job, the status changes to the RUNNING state.

Features of AWS App Runner

AWS App Runner provides various features to deploy the services. Let's know some features of it.

Auto Scaling

AWS App Runner scales the service according to the application's needs. It is enabled by default in this service. So, it automatically scales up and down the number of containers whenever required.

Load Balancing

A load balancer is used to distribute traffic among application servers equally. This feature is also enabled by default in AWS App Runner. It automatically balances the heavy traffic for the application and provides highly reliable and available service.

Automatic Deployments

Automatic deployment is one of the most important features of AWS App Runner. We have to choose this while creating the services. It automatically builds and deploys the application whenever we update the source code of Github or the container image of Amazon ECR.

Logs and Metrics

AWS App Runner also gives us the features to monitor the logs. It is easy to optimize the containerized applications with the help of details of build, deployment, and runtime logs. It provides a complete set of computing metrics with built-in AWS CloudWatch service.

Networking

AWS App Runner provides flexibility in communicating with different services and applications. It offers good networking compliance and security. App Runner services easily communicate with the other AWS service in an Amazon Virtual Private Cloud. We can also configure the App Runner service to be accessible only inside the Virtual Private cloud.

AWS App Runner Use Cases

Let's explore some of the Use cases of AWS App Runner.

Build Frontend and Backend Applications

We can use AWS App Runner to build and run different services. We can build frontend and backend applications using this service. It helps build and run API services, backend web services, websites, and more using Containerized Instances.

Run Thousands of Microservices Simultaneously

AWS App Runner is very flexible in scaling up and down the container according to the need. So it can run thousands of microservices simultaneously. This scaleable component decreases the risk of application resiliency and fosters increased agility.

Improve Time to Market

AWS always keeps the best practices and technologies to build and deploy web applications. AWS App Runner is also one of them. Its various features, like auto-scaling, load balancing, etc., help to improve the time to market efficiently.

AWS App Runner Pricing

AWS follows a pay-as-you-go model. You need to pay only for what you use. In AWS App Runner, we are charged for computing and memory resources used by the application. All container instance billing is processed per second and rounded up to the next nearest second.

Provisioned Container Instances

After the deployment of the application, we have to pay for the memory required to launch in a container instance. When the application is idle, it should deliver consistently low millisecond latency because the memory is provisioned. The pricing for Provisioned Container Instances is $0.007 / GB-hour, which is applicable in all the supported regions except the Asia Pacific (Tokyo) Region. In the Tokyo region, pricing is $0.009 / GB-hour.

Active Container Instances

It also charges as per the active container instances, using the storage and the CPU. Listed below are the configurations supported for the active container instances.

configurations supported

The pricing for Active Container Instances is $0.007 / GB-hour and $0.064 / vCPU-hour, which is applicable in all the supported regions except the Asia Pacific (Tokyo) Region. In the Tokyo region, pricing is $0.009 / GB-hour for the memory and $0.081 / vCPU-hour for the CPU.

Some Add-ons charges are also there, like, for Automatic deployments, $1 / application per month, and for the Build fee, $0.005 / build-minute is being charged by the AWS App Runner.

Getting Started with AWS App Runner

Let's run our application using the AWS App Runner service.

Prerequisites

Before launching our application, we need to get the following things done.

  1. For this demo, I am using my administrator account, which has all the access. (Otherwise, create an IAM (Identity and Access Management) user in your AWS account and generate an access key for the IAM user created.)
  2. Create a GitHub repository (here, we are using a GitHub repository named Demo_AppRunner). This repository contains a simple application that prints hello messages.
    • Go to your GitHub account and click on New to create a new repository. github account dashboard
    • Fill in the Repository name, and create the repository. create repository
    • Click on creating a new file. create new file
    • Create a file with name requirements.txt with code:pyramid==2.0 create file name requirements txt
    • Write a commit message and commit the changes. write commit message
    • Click on Add file and Create a new file. click add file options
    • Create a server file with the code:
    create server file
    • Write a commit message and commit the changes. write commit message2
    • Our Repository is now complete and good to use for the demo. demo repository

We completed the Prerequisites part. Let's create the App Runner service.

Create an App Runner Service

Creation of App Runner in AWS involves the following steps:

  1. Log in to the AWS console and search for the AWS App Runner in the search bar. Click on AWS App Runner. aws app runner on aws console
  2. This App Runner service is only supported in a few regions, so it will suggest choosing the region in which this service is available. app runner service supported in few regions
  3. It will go to the AWS App Runner service console page. Click on Create an App Runner service. aws app runner service console page
  4. We are on the creation page of AWS App Runner, which requires a source type to continue. Select the Source Code repository and click on Add new. new source code repository
  5. It will open a new window connecting to GitHub, logging in, and authorizing it. Click on Authorize AWS connector for GitHub. authorize aws connector for github
  6. Fill in the Connection name and click on Install another. connection name
  7. Next page, select your GitHub account. selecting github account
  8. It will ask which repository we want to connect to, either all or any of the repositories. selecting repository to connect
  9. Click on only select repository and choose the repository Demo_AppRunner. Click on install. selecting demo apprunner
  10. Now, it will show the GitHub account. Click on Next. selecting github account and connection
  11. The tab is closed automatically, and the GitHub repository is added to the Source and deployment page of AWS App Runner. Choose the Deployment setting as Automatic so that our app will automatically deploy the latest version when we update our repository. Click on Next. deployment setting as automatic
  12. After that, we have to configure the build setting. Choose the configuration of all settings here. We have a python file, so we must select Runtime as python 3. Fill the build command as pip install -r requirements.txt. We have to execute the python server file in the start command, so our start command is python server.py. In the port, it is already , so leave it as default and click on Next. configure build setting`
  13. Now, we have to set the service name virtual CPU and memory for this service. In the server file of our repository, we have an environmental variable NAME. Let's provide value to it. set service name virtual cpu and memory
  14. Leave all the other security, networking, and fields as default and click Next. set service name virtual cpu and memory
  15. Next, review the entries from the source and deployment page. review entries from source and deployment page
  16. Review all the configuration builds and services and click on Create & deploy. review configuration build
  17. It will take time to deploy the application and show the status as running. deploy application and status
  18. Click on the default domain URL to go to the created page, which shows Hello, and the value of the environmental variable. default domain url created page

We successfully created an AWS App Runner service.

Change the Service Code

Let's change our code on GitHub and see how it works.

  1. Open the server file on GitHub and click on the pencil icon to edit. server file on github
  2. Edit the text Hello to Good morning. text hello to good morning
  3. Write a commit and commit the changes to the server file. write commit
  4. Go to the AWS App Runner service. We see it is automatically deploying again as we changed our code on the GitHub repository. aws app runner service
  5. After a few minutes, it will show successfully deployed. demoapp runner successfully deployed
  6. Go to the App page and refresh it. Now it will show Good Morning and the value of key NAME. app page and value of key

We changed the service code and successfully deployed it.

Make a Configuration Change

We make a configuration change and observe its behavior.

  1. Go to the AWS App Runner and click on the configuration tab. aws app runner configuration tab
  2. In the configuration service, click on edit and set the value of NAME as Jane. Choose the Apply changes. configuration service and set value of
  3. The status of the DemoAppRunner is now Operation in progress. After a few minutes, it is again on running status. status of demoapprunner
  4. Go to the App page and refresh it. Now it will show Good Morning and the value as Jane. app page and value

We successfully make a configuration change, and it deploys automatically.

View Logs for Your Service

We can see the logs on the Logs tab of the AWS App Runner console.

logs on logs tab of aws app runner console

We can see the Event logs, Deployment logs, and Application logs. We can download these logs and also view this on ClouWatch.

Clean Up

We created the AWS App Runner service and launched an application. Now clean up the services and delete the AWS App Runner.

  • Go to the AWS App Runner console and click on Actions. app runner console and actions
  • Click on Delete, which will start cleaning the service and deleting the application on AWS App Runner. delete application on aws app runner

We completed the demo of Getting started with AWS App Runner.

AWS App Runner Supported Regions

AWS App Runner provides its services only in limited regions, which include the following:

  • US East (N. Virginia)
  • US East (Ohio)
  • US West (Oregon)
  • Europe (Ireland)
  • Asia Pacific (Tokyo)

Benefits of AWS App Runner

AWS App Runner has a lot of benefits to deploying web applications on containerized instances. They are:

  • It is easy to use to build and deploy the web application.
  • AWS App Runner provides a custom domain name.
  • AWS App Runner is a well-scalable and budget-friendly service for deploying applications.
  • It has built-in features of Cloudwatch to check all the events, deployment, and application logs to review the web applications.
  • It gives a better cost management service, i.e. it provides the facility to pause and resume the App Runner service. We have to pay only when the service is running.
  • AWS fully manages AWS App Runner. So, there is no need to set up TLS for web applications. It also renews the certificates before their expiration date automatically.

Conclusion

  • AWS App Runner is a fully managed service of Amazon that deploys containerized web applications and APIs at scale.
  • App Runner uses the source code repository from GitHub and source image from the Amazon ECR to deploy the applications.
  • Features of AWS App Runner include:
    • Autoscaling
    • Load balancing
    • Automatic deployments of the updates
    • Networking
    • Logs on CloudWatch
  • AWS App Runner has various use cases in Build Frontend and Backend Applications, Microservices-based apps run Thousands of Microservices Simultaneously, etc.
  • Its pricing is very cost management. We have to pay only when the service is running.
  • The pricing differs on whether we are using Provisioned container instances or Active container instances.
  • AWS App Runner service is currently supported in limited regions only.