Getting Started with AWS App Runner

Getting Started with AWS App Runner

Building, Deploying and Running Containerized Web Applications with AWS App Runner

Table of contents

No heading

No headings in the article.

AWS App Runner is a fully-managed service that lets you easily build, deploy, and run containerized web applications and APIs in the cloud. By using AWS App Runner, developers can focus on writing code and deploying their application, without worrying about infrastructure setup, maintenance or scaling.

To build a web app on AWS using AWS App Runner, you can follow these steps:

  1. Create a containerized application: First, you need to create a containerized application with a Dockerfile. The Dockerfile will define the instructions to build the container image for your application.

Here's an example Dockerfile for a simple Node.js app:

# Use the official Node.js runtime as a parent image
FROM node:14

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed dependencies
RUN npm install

# Make port 8080 available to the world outside this container
EXPOSE 8080

# Run the app when the container launches
CMD ["npm", "start"]
  1. Push the container image to Amazon ECR: Once you have created the Dockerfile, you can build and push the container image to Amazon Elastic Container Registry (ECR). ECR is a fully-managed container registry that makes it easy for developers to store, manage, and deploy Docker container images.

  2. Create an AWS App Runner service: After you have pushed the container image to ECR, you can create an AWS App Runner service. The service will define the configuration and parameters for deploying and running your containerized application.

Here's an example command to create an AWS App Runner service:

aws apprunner create-service --service-name my-web-app --source-configuration-repository-url https://my-ecr-repository-url --instance-configuration-memory 1GB --instance-configuration-cpu 1vCPU --auto-deployment-enabled

This command creates an AWS App Runner service named "my-web-app" and sets the source configuration to the ECR repository URL. It also configures the instance size to use 1GB of memory and 1 vCPU. Finally, it enables auto-deployment, which automatically deploys updates to your application.

  1. Accessing your web app: Once your application has been deployed, you can access the web application by visiting the provided URL. You can find the URL by running the following command:
aws apprunner describe-service --service-arn <your-service-arn>

That's it!

You've now successfully built a web app on AWS using AWS App Runner. This service makes deploying and running containerized web applications and APIs fast and easy, with little to no infrastructure maintenance needed.