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.
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 Create → Repository in the top menu.
Figure 2 : Creating a repository in Bitbucket
In the next screen:
- Choose Import repository from the Create a new repository dialog
- In the Old Repository URL, enter https://github.com/aws-containers/hello-app-runner.git
- Select the Workspace
- Create a new Project called app-runner-demo
- Name the repository hello-app-runner
- If you want the repository to be public, then uncheck This is a private repository. AWS App Runner supports public and private repositories
- Select Import repository
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:
- In Repository type, select Source code repository
- Select Bitbucket as the Provider
- Choose the Add new button to connect your Bitbucket account
Figure 4 : Source setup for AWS App Runner deployment
In the next screen:
- Enter a Connection name
- 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.
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.
Figure 6 : Creating a new connection for Bitbucket integration
Configure the repository and branch in Bitbucket settings:
- Set the Repository to hello-app-runner
- Set the Branch to main
Figure 7 : AWS Connector for Bitbucket setup
Keep the deployment trigger to manual.
Next, we’ll configure runtime and build settings:
- Select Configure all settings here
- Select Python 3 as the Runtime
- Enter Build command:
yum install -y pycairo; pip install -r requirements.txt
- Enter Start command:
python app.py
- Set Port to 8000
In service settings:
- Enter Service name: hello-app-runner
- Set Virtual CPU to25 vCPU and Virtual memory to 0.5 GB
Figure 8 : Build configurations 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.
Figure 10 : Viewing 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.
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:
- Delete the AWS App Runner service
- Delete AWS App Runner connection resource that connects to Bitbucket account
- Delete service and application logs in Amazon CloudWatch by deleting any log groups beginning with
/aws/apprunner/hello-app-runner/
- 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.