Skip to content

Guide on deploying a `flask` app on AWS running: `celery`, `celery_beat`, and `celery_flower`, with a `nginx` container as the entry point

License

Notifications You must be signed in to change notification settings

programmingwithalex/aws_flask_celery

Repository files navigation

Contributors Forks Stargazers Issues BSD-3-Clause License



Copyright (c) 2025, GitHub@programmingwithalex

Flask, Celery, & Nginx - AWS Deployment

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
  1. Series Outline
  2. Getting Started
  3. AWS (CDK) Commands
  4. References

Series Outline

  1. Explain the codebase configurations to understand how the different components interact

    • docker-compose.yml and each of the separate containers
    • nginx.conf
    • Dockerfile and Dockerfile_nginx
    • environment variables
    • flask app files and the configuration of the celery components
  2. Get aws_flask_celery_app example running locally using docker-compose

  3. 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
  4. 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
  5. Use GitHub Actions to automate deployments to AWS ECS components, referred to as Continuous Deployment (CD)

  6. Create networking setup and ECS components automatically with a single script using AWS CDK

(back to top)

AWS Components

  • 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

(back to top)

Getting Started

Prerequisites

Software

AWS

CMD Line

  • follow setup guides for aws-cli if not already configured

Google Mail Credentials

  • 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

(back to top)

AWS Cloud Development (CDK)

Installation (Windows)

  • download node.js, includes npm which is necessary to install the aws-cli
  • install aws-cdk
npm install -g aws-cdk

Commands

  • cdk init app --language python - create the initial CDK app locally
  • cdk bootstrap - deploying the AWS CDK for the first time
  • cdk synth - constucts CloudFormation template and does some verification checks
  • cdk deploy --all - deploy all CDK components
  • cdk 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

References

create ALB

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.

CDK Workshop

Instructions on using the AWS Cloud Development Kit (CDK)

About

Guide on deploying a `flask` app on AWS running: `celery`, `celery_beat`, and `celery_flower`, with a `nginx` container as the entry point

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published