Skip to content

CDK example on how to build a 3 Tier Architecture

Notifications You must be signed in to change notification settings

rluberti/CDK-3TA

Repository files navigation

CDK-3TA

CDK example on how to build a Web 3 Tier Architecture. It is an example for training purpose DON'T USE IT IN PRODUCTION. Project's location: https://github.com/rluberti/CDK-3TA/

Introduction

The AWS Cloud Development Kit (AWS CDK) is an open source software development framework to define your cloud application resources using familiar programming languages (see https://aws.amazon.com/cdk/). This project is a basic example in Python on how to create a classic Web 3 Tier Architecture (Web / App / DB Tiers, see https://en.wikipedia.org/wiki/Multitier_architecture#Three-tier_architecture).

Features

Architecture

Installation

Requirements

Steps

  • Clone repository
  • git clone https://github.com/rluberti/CDK-3TA.git
  • Create Python Virtual Environment
  • cd CDK-3TA
  • python3 -m venv .venv
  • Run Virtual Environment
  • source .venv/bin/activate
  • Install Python packages
  • pip3 install aws-cdk.aws-codedeploy aws-cdk.aws-rds
  • Check if CDK can create CloudFormation code running:
  • cdk synth
  • Create Stack deploying the code on AWS CloudFormation:
  • cdk deploy
  • It will display the Web public DNS entry point as "CDK-3TA-Stack.WebALBDNS"
  • Delete Stack
  • cdk destroy

Usage

  • Use http://<CDK-3TA-Stack.WebALBDNS>/ to hit the Web tier only and get its output
  • Use http://<CDK-3TA-Stack.WebALBDNS>/app to hit Web tier first, then App tier and get its ouput
  • Use http://<CDK-3TA-Stack.WebALBDNS>/db to hit Web tier first, App tier second and DB tier at the end with its output
  • Connect via SSM session to any EC2 instance and run utility stress --cpu 2 to make total CPU utilization spike to over 40% and trigger scaling up to 4 instances.