Coder Social home page Coder Social logo

aws-scalable-website's Introduction

aws-scalable-website

This repository provides AWS cloud formation templates to create a scalable web site. Includes:

  • CFN template to create a VPC Stack
  • CFN template to create a scalable website stack
  • Template wesite site files

Create the Full Stack

Follow the steps

Step 1

Create a VPC with subnets for hosting the website stack.

The folder cfn-templates has the required files to create the VPC and related components vpc-stack.yml: the CloudFormation template to create the base VPC, Subnets, NAT Gateways, etc which will be used by the main stack. vpc-params.json: is the parameters file which contains the parameter values for the CFN template. Update the values as appropriate. From the repo root directory execute the following AWS CLI command to create the VPC.

aws cloudformation create-stack --stack-name TestSite-BaseStack --template-body file://cfn-templates/vpc-stack.yml --parameters file://cfn-templates/vpc-params.json

Step 2

Install website files to an S3 bucket within the AWS account.

The website CFN template downloads the website files from an S3 bucket. Sample website files are included in the 'site-files' directory. To upload these files to S3, go to the root directory and execute the following commands.

Create a new S3 bucket:

aws s3 mb s3://my-testwebsite-files

Copy files to newly s3 bucket

aws s3 cp ./site-files s3://my-testwebsite-files --recursive

Step 3

Create the Website stack

The folder cfn-templates has the required files to create the stack to host the site and required components.
cfn-scalable-website.yml: the CloudFormation template to create the components of a stack hosting a scalabale web application. teststack-params.json: is the parameters file which contains the parameter values for the CFN template.

Update the values for the VpcId, PrivateSubnet1, PrivateSubnet2, PublicSubnet1, PublicSubnet2 based on the values in the output section of the base VPC stack created in Step 1. Update WebsiteFilesS3Bucket to the S3 bucket created in Step 2. Update KeyPairName value with an existing key pair or create a new key pair and use it.

Go to the repo root directory and execute the following AWS CLI command to create the scalable website.

Note The CFN template is configured to accept only T2 instance types, in regions eu-west-1,eu-west-2, us-west-1, us-east-2, us-east-1, and us-east-2.

aws cloudformation create-stack --stack-name TestSite-MainStack --template-body file://cfn-templates/cfn-scalable-website.yml --parameters file://cfn-templates/teststack-params.json --capabilities CAPABILITY_IAM

Application Maintenance

Monitoring

The CloudWatch Alarm 'TestWebsite ALB Healthy Host Count' monitors the healthy host count, a SNS notificattion can be created to be notified if this in in Alarm state.

Scaling

  • At Stack Creation - The stack is configured to create one web instance at creation. To Change this, update the paramter WebServerCapacity to the desired value (If more than 5 instances are required at launch time, the MaxSize in the Auto Scaling configuration must also be updated)
  • Manually - Change the 'Desired', 'Min,. 'Max', parameters on the auto scaling group as appropriate
  • By CPU Usage - the Cloud watch alarm 'CPUUsageAlarmForTestWebsiteALB' will scale up the number of instances when the CPU is above 50% for 5 minutes. This can be modified when the stack is created or at runtime through the AWS console

aws-scalable-website's People

Contributors

b-massey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.