Deploy Flask Application on AWS Apprunner

Rushabh Mahale
4 min readApr 27, 2023

--

Industries use PaaS and containerization to streamline software development and deployment. PaaS provides a platform for developing, testing, and deploying applications without managing infrastructure. Containers reduce virtual machine overhead and increase efficiency, allowing for easy application movement between environments. PaaS also offers automatic scaling and high availability for applications during traffic spikes. This approach increases speed, agility, and flexibility, meeting customer demands and adapting to a constantly changing market.

Pre-requisites

  1. Create a Flask application in my case I have created a python flask application you can go through GitHub URL.
  2. Push your docker image to ECR
  3. Here is a blog link to how you can integrate GitHub with Apprunner

What is AWS-Appruner?

AWS AppRunner is a service that streamlines the deployment of containers. Containers are used by developers to bundle their apps and dependencies into a single entity that can be transported easily across environments. AppRunner automates container deployment and scaling automatically, allowing developers to focus on designing their apps.

Follow this link to know more about Apprunner.

Steps to Create Apprunner

Step 1 Go to AWS Console and search for Apprunner

Note- App runner supported region

  • Supported Regions
  • Europe (Ireland)
  • Asia Pacific (Tokyo)
  • Asia Pacific (Singapore)
  • Asia Pacific (Sydney)
  • Europe (Frankfurt)
  • US East (N. Virginia)
  • US East (Ohio)
  • US West (Oregon)

Step 2 Select Container registry you can also select code repository this will go to your SCM tools like GitHub, GitLab, and Bitbucket. and it will automatically detect Dockerfile build and deploy it to Apprunner. select your ECR repository.

Step 3 Create access Role I have selected manual

  • Manual- This will run the version you have deployed your image and whenever another version it will not pull the image from ECR
  • Automatic- In Automatic we have this feature whenever a new version comes it will detect and trigger Apprunner to deploy a new version of the image.

Step 4 Here is the Configuration of service where your Container app is running if you have a Tomcat server running a Java application with complex code which requires lots of RAM and VCPU so we can also select the necessary CPU and memory according to your application.

Step 5 you can also define autoscaling you can configure your own also I am selecting the default one.

Step 6 Health Check part will continuously check your application's health state.

Step 7 Networking Traffic should be accessible within your VPC or exposed to the public next are tags which are optional.

Step 8 There is a feature you can also add AWS X-ray which is a reliable and analyze and debug distributed applications service in AWS

  • Analyze & debug applications using distributed tracing
  • Pinpoint & understand the root cause of issues, errors, and bottlenecks
  • Preview of AWS X-RAY support for AWS Lambda and other serverless applications.
  • Identify which part of the application is causing the issue.
  • It allows you to see details about requests being made to the app.
  • Provides a visual map of the application’s architecture.

Deploy and Create

This will show real-time deployment logs. You can also Download the logs.

Step 9 Here is our application Copy URL and paste it into the browser you will see your Flask application is running on Apprunner. Here is How I deploy using ECR Next blog Aniket Kumavat has explained how Apprunner works with GitHub and deploys your application.

Here is the blog link.

Conclusion

AWS AppRunner simplifies the process of deploying and scaling containerized apps in the cloud by offering a fully managed solution for developers. With automated scalability, monitoring, and built-in security, AppRunner allows developers to focus on developing code and constructing apps without worrying about infrastructure maintenance. This makes application deployment faster, easier, and more cost-effective. Additionally, AppRunner provides a simple and scalable approach for launching containerized apps, giving teams the benefits of cloud technology while saving time and resources.

In case of any questions regarding this article, please feel free to comment in the comments section or contact me via LinkedIn.

I want to thank my team at Guysinthecloud for all of their help.

Thank You

--

--