Skip to content

ndhoanit1112/django-cicd-aws-cdk

Repository files navigation

AWS CDK Infrastructure for Django CI/CD project

This AWS CDK (Cloud Development Kit) project provides infrastructure automation for deploying Django deploy CI/CD project on AWS.

Prerequisites

Before getting started with this project, ensure that you have the following prerequisites:

Getting Started

Follow these steps to set up and deploy the infrastructure:

  1. Clone this repository to your local machine:
git clone https://github.com/ndhoanit1112/django-cicd-aws-cdk
cd django-cicd-aws-cdk
  1. Modify some environment variables in the env folder:

    Open env/dev.yml and env/prod.yml files

  1. Install project dependencies:
npm install
  1. Configure your AWS credentials using the AWS CLI:
aws configure
  1. Synthesizes AWS CloudFormation templates:
npx aws-cdk synth --all
  1. Deploy the infrastructure stacks to AWS:
npx aws-cdk deploy --all

This command will deploy all the stacks defined in the project.

  • Note: If you want to deploy to the production environment, add the DEPLOY_ENV=prod environment variable to your deployment command. For example:
DEPLOY_ENV=prod npx aws-cdk deploy --all

Architecture

This project creates the following AWS resources:

  • VPC Stack: Establishes a Virtual Private Cloud (VPC) with public and private subnets, routing tables, and internet gateway for network isolation and security.
  • Secrets Manager Stack: Sets up AWS Secrets Manager to securely store sensitive information like database credentials.
  • ECR Stack: Sets up the Elastic Container Registry (ECR) to store Docker container images for the Django application.
  • ECS Stack: Creates an Elastic Container Service (ECS) cluster and task definitions for running the Django application as a containerized service.
  • ELB Stack: Configures an Application Load Balancer (ALB) to distribute incoming traffic across the ECS service.
  • RDS Stack: Deploys an Amazon RDS database instance to store the application's data.
  • SQS Stack: Creates an Amazon Simple Queue Service (SQS) queue for handling background tasks or message processing. In this project, it is used to perform calculations of Fibonacci numbers as a background task.
  • Cache Stack: Sets up a Memcached cluster to store and retrieve calculated Fibonacci numbers, reducing the need to recalculate them repeatedly.
  • Pipeline Stack: Configures an AWS CodePipeline to automate the deployment process, triggering builds and deployments on every code change.
  • EFS Stack: Sets up a shared file system between ECS tasks (This stack doesn't support the funtionality of the application, it is for study/experimental purpose).

Clean Up

To remove the deployed infrastructure from your AWS account, run the following command:

npx aws-cdk destroy --all

This command will delete all the stacks created by the AWS CDK project.

About

AWS CDK app for django-cicd-aws project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published