Copyright (c) 2025, GitHub@programmingwithalex
Guide on deploying a flask app on AWS running: celery, celery_beat, and celery_flower, with a nginx container as the entry point
YouTube Demo
·
Report Bug
·
Request Feature
Table of Contents
-
Explain the codebase configurations to understand how the different components interact
docker-compose.yml
and each of the separate containersnginx.conf
Dockerfile
andDockerfile_nginx
- environment variables
flask
app files and the configuration of thecelery
components
-
Get
aws_flask_celery_app
example running locally usingdocker-compose
-
Create working example of
aws_flask_celery_app
on AWS using ECS- will not be production ready
- will rely on a lot of default values provided by AWS, with no networking setup by us
S3
for environment variable storage
-
Create production-ready example of microservices on AWS using ECS
- configure networking setup and apply that to ECS components
SSM Parameter Store
for environment variable storage
-
Use GitHub Actions to automate deployments to AWS ECS components, referred to as Continuous Deployment (CD)
-
Create networking setup and ECS components automatically with a single script using AWS CDK
- Virtual Private Cloud (VPC)
- NAT Gateway & Internet Gateway (IGW)
- Elastic Container Registry (ECR)
- Elastic Container Service (ECS)
- ECS Clusters
- ECS Services
- ECS Task Definitions
- Application Load Balancer (ALB)
- S3
- SSM Parameter Store
- AWS Cloud Development Kit (CDK)
- written in Python
- Python: version requirement determined by AWS CLI requirement and optionally AWS CDK requirement
- Docker Desktop: account not required, just installation
- create AWS IAM user account than can be configured with the AWS CLI
- follow setup guides for
aws-cli
if not already configured
- must have credentials for either gmail or another provider to send emails with
- if using 2FA for gmail account, must get an app password from here
npm install -g aws-cdk
cdk init app --language python
- create the initial CDK app locallycdk bootstrap
- deploying the AWS CDK for the first timecdk synth
- constucts CloudFormation template and does some verification checkscdk deploy --all
- deploy all CDK componentscdk destroy --all
- destroys all CDK components- issue with calling because of Fargate Cluster dependency -
FargateCluster/FargateCluster (...) Resource handler returned message: "The specified capacity provider is in use and cannot be removed.
- if called twice then all elements will be deleted
- issue with calling because of Fargate Cluster dependency -
If your service's task definition uses the awsvpc network mode (which is required for the Fargate launch type), you must choose IP addresses as the target type. This is because tasks that use the awsvpc network mode are associated with an elastic network interface, not an Amazon EC2 instance.
Target group port when using ALB
Protocol port will be overriden by ECS anwyays so doesn't matter.
Instructions on using the AWS Cloud Development Kit (CDK)