Containers

Announcing AWS App Runner support for Bitbucket

Introduction

AWS App Runner is a fully managed container application service that lets you build, deploy, and run containerized web applications and API services without prior infrastructure or container experience. Starting today, AWS App Runner supports building and deploying services from Bitbucket repositories. This post walks you through the process of deploying a sample AWS App Runner service when the source code is stored in a Bitbucket repository.

Developed with AWS operational, security, and configuration best practices, AWS App Runner eliminates the need for customers to manage infrastructure, servers, or container orchestrators. AWS maintains and manages the infrastructure running your applications, which means that your teams get to production quickly and efficiently.

AWS App Runner is built for web scale, so there’s no need to re-platform or re-architect as the business grows. It helps you rapidly deliver innovative solutions and add business value. AWS App Runner is the easiest way for customers to run their web applications (including APIs, backend web services, and websites) on AWS.

Solution overview

Deploying applications in AWS App Runner

AWS App Runner offers two easy ways to deploy applications. AWS App Runner can build and deploy your code from source code or you can provide App Runner a prebuilt container image. In addition to GitHub, AWS App Runner can now retrieve your source code from a Bitbucket repository.

You can use the Continuous Integration/Continuous Delivery (CI/CD) capability of AWS App Runner to track changes to your source code or images. This functionality allows you to trigger automatic deployments whenever new code is pushed to the Git branch.

In the following walkthrough, we deploy an AWS App Runner service from source code. The source code is hosted in a Bitbucket repository, which is where AWS App Runner builds the application and deploys a highly available endpoint.

AWS App Runner Service builds source code from Bitbucket and deploys an endpoint.

Figure 1: AWS App Runner service deployed from source code

Walkthrough

Clone the sample repository

Login to your Bitbucket account and open the Dashboard. Switch to a non-production workspace and create a new repository by selecting CreateRepository in the top menu.

Creating a repository in Bitbucket

Figure 2 : Creating a repository in Bitbucket

In the next screen:

  1. Choose Import repository from the Create a new repository dialog
  2. In the Old Repository URL, enter https://github.com/aws-containers/hello-app-runner.git
  3. Select the Workspace
  4. Create a new Project called app-runner-demo
  5. Name the repository hello-app-runner
  6. If you want the repository to be public, then uncheck This is a private repository. AWS App Runner supports public and private repositories
  7. Select Import repository

Importing code repository into Bitbucket

Figure 3 : Importing code repository into Bitbucket

Once the code has been imported, go to hello-app-runner repository and verify that it contains files.

Deploy AWS App Runner service

Now that we have the code in our Bitbucket repository, let’s deploy an AWS App Runner service.

Open the AWS Management Console and navigate to the AWS App Runner. Go to the Services menu and select the Create Service button.

On the next screen, select:

  1. In Repository type, select Source code repository
  2. Select Bitbucket as the Provider
  3. Choose the Add new button to connect your Bitbucket account

Source setup for AWS App Runner deployment

Figure 4 : Source setup for AWS App Runner deployment

In the next screen:

  1. Enter a Connection name
  2. Since this your first time using Bitbucket with AWS App Runner, choose Install another

You’ll be redirected Bitbucket to grant your access and is where you can select your workspace.

AWS CodeStar access for Bitbucket integration

Figure 5 : AWS CodeStar access for Bitbucket integration

Once you’ve granted access, you’ll be redirected to AWS Management Console. Verify that the Bitbucket application is set to the correct Bitbucket workspace and select Next.

Creating a new connection for Bitbucket integration

Figure 6 : Creating a new connection for Bitbucket integration

Configure the repository and branch in Bitbucket settings:

  1. Set the Repository to hello-app-runner
  2. Set the Branch to main

AWS Connector for Bitbucket setup

Figure 7 : AWS Connector for Bitbucket setup

Keep the deployment trigger to manual.

Next, we’ll configure runtime and build settings:

  1. Select Configure all settings here
  2. Select Python 3 as the Runtime
  3. Enter Build command: yum install -y pycairo; pip install -r requirements.txt
  4. Enter Start command: python app.py
  5. Set Port to 8000

In service settings:

  1. Enter Service name: hello-app-runner
  2. Set Virtual CPU to25 vCPU and Virtual memory to 0.5 GB

Build configurations in AWS App Runner

Figure 8 : Build configurations in AWS App Runner

Service settings in AWS App Runner

Figure 9 : Service settings in AWS App Runner

Keep other settings to their defaults and choose the Next button. Verify the configuration on the following screen and click Create and deploy.

AWS App Runner deploys an application behind a managed load balancer with a Transport Layer Security (TLS ) certificate. Your application also autoscales based on concurrent requests. AWS App Runner sends metrics and container logs to Amazon CloudWatch.

You can see the deployment logs by opening the Create service event logs in the AWS App Runner dashboard.

Viewing logs in AWS App Runner

Figure 10 : Viewing logs in AWS App Runner

Deployment Logs in AWS App Runner

Figure 11 : Deployment Logs in AWS App Runner

The build and deployment takes about 5 minutes. Once your application is ready, you can access it by opening the default domain endpoint.

Application live on AWS App Runner

Figure 12 : Application live on AWS App Runner

Prerequisites

You’ll need these tools to follow the walkthrough:

  • An AWS account with ability to create new services in AWS App Runner
  • A Bitbucket account

Include an AWS account, AWS resources, specialized programming skills, or specific hardware or software.

Cleaning up

You continue to incur cost until you delete the infrastructure that you created for this post.

Delete the following resources created during this demonstration:

  1. Delete the AWS App Runner service
  2. Delete AWS App Runner connection resource that connects to Bitbucket account
  3. Delete service and application logs in Amazon CloudWatch by deleting any log groups beginning with /aws/apprunner/hello-app-runner/
  4. Delete the newly created repository in Bitbucket account

Conclusion

In this post, we showed you how to deploy an AWS App Runner service from source code hosted in a Bitbucket repository. AWS App Runner successful built the application from source code and deploy a highly available endpoint. We highly recommend that you try out this new feature of AWS App Runner for your product deployments. Learn more about AWS App Runner from our documentation and developer guide.

Re Alvarez-Parmar

Re Alvarez-Parmar

In his role as Containers Specialist Solutions Architect at Amazon Web Services, Re advises engineering teams with modernizing and building distributed services in the cloud. Prior to joining AWS, he spent more than 15 years as Enterprise and Software Architect. He is based out of Seattle. Connect on LinkedIn at: linkedin.com/in/realvarez/

Elamaran Shanmugam

Elamaran Shanmugam

Elamaran (Ela) Shanmugam is a Sr. Container Specialist Solutions Architect with AWS. Ela is a Container, Observability and Multi-Account Architecture SME and helps customers design and build scalable, secure and optimized container workloads on AWS. His passion is building and automating infrastructure to allow customers to focus more on their business. He is based out of Tampa, Florida and you can reach him on twitter @IamElaShan.

Hari Ohm Prasath

Hari Ohm Prasath

Hari is a Senior Software Development Engineer with App Runner and Elastic Beanstalk, working on new ways for customers to modernize their web applications on AWS. Hari loves to code and actively contributes to the open source initiatives. You can find him in Medium, Github & Twitter @hariohmprasath

Yuchen Lu

Yuchen Lu

Yuchen is a Software Development Engineer at AWS App Runner and Elastic Beanstalk. He is enthusiastic about cloud computing and serverless technologies, and aims to inspire fellow developers to effortlessly build and scale applications. You can find him on LinkedIn (linkedin.com/in/yuchen-l-450a38b0).