Coder Social home page Coder Social logo

avr-cdk-web-app's Introduction

aws-cdk-web-app-example

This is an example of how to build a resilient web application with just 30 lines lines of TypeScript code by using the AWS CDK. It consists of one Amazon Virtual Private Cloud (VPC) with private and public subnets in multiple Availability Zones, in which an Application Load Balancer and an Amazon EC2 Auto Scaling Group are deployed. The Application Load Balancer accepts requests via HTTP (port 80) and forwards them to the instances of the Auto Scaling Group. The Auto Scaling Group is using a Launch Configuration that contains a User Data script to install the Apache HTTP Server and serve a static HTML page.

Note: This example stack is intentionally not production-ready, in order to keep the sample short. Among other improvements, please take note of the suppressions that have been added to the stack for cdk-nag.

Deploying the CDK Stack

Set up CDK as described here. Then, use the following commands to install all dependencies and deploy the stack in your AWS account:

cd web-app
npm install
npm run build
cdk deploy

Accessing the test page

After deploying, the CDK CLI will return an output called WebAppStack.Hostname which is the hostname of the Application Load Balancer. Open this hostname in a web browser (via HTTP) to display the HTML page. Note that immediately after the deployment, you might see an error code of 502 because the instances of Auto Scaling Group have not finished installing the Apache HTTP Server yet. In this case, wait a few minutes and try again.

Testing the stack

This repository was scaffolded via cdk init sample-app --language typescript. This command also scaffolds a test workflow with jest. The test suite can be run with the command npm run test. To keep this example simple, the test suite only employs the method of snapshot testing.

avr-cdk-web-app's People

Contributors

486 avatar amazon-auto avatar avrobins 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.