Automated App Deployments with AWS App Runner and Github

Automated App Deployments with AWS App Runner and Github

Automating application deployments is a key practice in modern software development, enabling teams to deploy updates quickly and consistently. In this article, we’ll explore how AWS App Runner, in tandem with GitHub, offers a seamless solution for automating your deployment process. AWS App Runner simplifies the deployment of containerized web applications and APIs by managing the underlying infrastructure, allowing developers to focus on building and scaling their applications. By integrating with GitHub, App Runner streamlines the deployment workflow, enabling automatic deployments with each code push.

AWS App Runner

Prerequisites

Before we begin, ensure you have the following prerequisites in place:

  • An AWS account with appropriate permissions to create and manage App Runner services.
  • A GitHub account and a repository containing your application code.

What is AWS App Runner?

AWS App Runner offers a simple and intuitive solution for deploying containerized applications without the need to manage the underlying infrastructure. It supports Docker images and automatically deploys them, provisioning and configuring the necessary resources to run your application in a scalable and secure manner.

Key Features and Benefits:

  • Serverless Architecture: App Runner follows a serverless approach, eliminating the need to provision and manage servers. AWS handles the underlying infrastructure, freeing you from operational overhead.

  • Automatic Deployment: App Runner automatically deploys your applications from your source repository, simplifying and accelerating the deployment process.

  • Automatic Scaling: The service automatically scales your application up or down based on traffic patterns, ensuring optimal performance and efficient resource utilization.

  • Container-based Deployment: Your application is packaged and deployed as a container image, ensuring consistent behavior across different environments and simplifying deployment workflows.

  • Source Code Integration: App Runner seamlessly integrates with popular source control services like GitHub, enabling you to deploy new versions of your application directly from your code repository.

Differences from Similar AWS Services

Compared to other AWS services such as Amazon ECS (Elastic Container Service) and Amazon EKS (Elastic Kubernetes Service), AWS App Runner stands out for its ease of use and fully automated infrastructure management. While ECS and EKS offer more granular control over container orchestration, App Runner aims to simplify the deployment process for developers seeking a quick and effortless solution.

Understanding the Architecture of AWS App Runner

AWS App Runner simplifies the process of deploying and managing web services by abstracting away the underlying infrastructure complexities. At its core, App Runner takes your source code or pre-built container image and creates a fully managed and scalable web service running in the AWS Cloud.

The deployment process is remarkably straightforward: you typically need to invoke just one App Runner action, CreateService, to kickstart your web service deployment. App Runner supports two deployment methods:

  1. Source Code Deployment: If you provide your application’s source code, App Runner can retrieve it from popular code repositories like GitHub or Bitbucket. The service then automatically builds a container image using AWS CodeBuild, targeting the appropriate runtime environment based on your application’s programming language and framework.

  2. Container Image Deployment: Alternatively, you can provide a pre-built container image, which App Runner can retrieve from your Amazon Elastic Container Registry (Amazon ECR) repository within your AWS account.

Regardless of the deployment method, App Runner takes care of provisioning and managing the necessary infrastructure components behind the scenes.

Hands-On: Deploying from GitHub to AWS App Runner

Now that we’ve explored the key concepts and architecture behind AWS App Runner, let’s put our knowledge into practice by deploying a real-world application from a GitHub repository to App Runner.

For this hands-on example, we’ll use a simple Spring boot application hosted on GitHub.

Step 1: Connect GitHub to AWS App Runner

  1. Log in to the AWS Management Console and navigate to the App Runner service.
  2. Click Create a service.

create-service

  1. Under Source, select "Source code repository" then Github as the source provider.

source-code

  1. Click Connect to GitHub and follow the prompts to authorize App Runner to access your GitHub account and repositories.

Step 2: Configure the Deployment Source

  1. After connecting to GitHub, select the repository containing your application code.
  2. Specify the branch you want to deploy (e.g., main or development) and your application directory.

github-connection

  1. Under the "Deployment settings" section, select "Automatic" to allow App Runner to automatically update your application whenever you push changes to the specified branch.

Step 3: Configure the Build

  1. Select the runtime environment compatible with your Application (e.g., Corretto 11).
  2. Provide the necessary build commands for your application (e.g., mvn clean package for Maven-based projects).
  3. Specify the start command to run your application (e.g., java -jar target/your-app.jar).
  4. Enter the port on which your application will listen for incoming requests.

deployment-setting

Step 4: Configure service

  1. Provide a name for your service.
  2. Specify the necessary vCPU and memory resources for your application based on its requirements.
  3. If your application requires environment variables, provide them in this step.
  4. Leave other settings at their default values, or adjust them as needed.
  5. Review the configuration and click Create & Deploy to initiate the deployment process.

service-creation

App Runner will now start building your application’s container image based on the provided source code and configurations. You can monitor the deployment progress from the App Runner console.

service-log

Step 5: Access Your Deployed Application

Once the deployment is complete, App Runner will provide you with a service URL where your application is accessible. Copy the URL and paste it into a web browser to verify that your application is up and running.

application

Step 6: Trigger an Automatic Deployment

One of the key benefits of integrating App Runner with GitHub is the ability to trigger automatic deployments whenever changes are pushed to your repository. Let’s test this functionality:

  1. Make a small change to your application code.

update-code

  1. Commit and push the changes to your GitHub repository.

App Runner will automatically detect the new commit and initiate a new deployment process. Monitor the deployment progress in the App Runner console, and once complete, refresh your application’s URL to see the updated changes.

new-service

application-update

Congratulations! You’ve successfully deployed your application to AWS App Runner and experienced the power of automatic deployments from GitHub. This workflow can significantly streamline your development and delivery processes, enabling faster iterations and more frequent updates to your applications.

Conclusion

In this article, we’ve explored how AWS App Runner, in combination with GitHub, simplifies and automates the deployment process of applications in the AWS cloud. By understanding the fundamentals of App Runner and following a practical application deployment scenario, we’ve seen how this solution offers an effortless approach to hosting your web applications and APIs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Press ESC to close