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.ymland each of the separate containersnginx.confDockerfileandDockerfile_nginx- environment variables
flaskapp files and the configuration of thecelerycomponents
-
Get
aws_flask_celery_appexample running locally usingdocker-compose -
Create working example of
aws_flask_celery_appon 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
S3for environment variable storage
-
Create production-ready example of microservices on AWS using ECS
- configure networking setup and apply that to ECS components
SSM Parameter Storefor 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-cliif 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-cdkcdk 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)