Skip to content

christian-deleon/portfolio-iac-aws-cdk-ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

My Personal Portfolio Infrastructure

Visit my Portfolio Website

About this Project

With the idea of showing off my skills, I have created a repository to list all of the ways I have designed infrastructures that run my portfolio using different IaC and cloud resources.

You can find that repository here: https://github.com/christian-deleon/portfolio-iac

The front end was designed and developed by me using React.Js, Javascript, HTML, and CSS.

Frontend Repository: https://github.com/christian-deleon/portfolio

Using AWS CDK ( Cloud Development Kit ) with AWS ECS Fargate running the web servers, I have created an application which uses Docker to containerize the Node.Js server and consists of the following AWS resources:

  • AWS ECS ( Elastic Container Service ) as the container service for the web servers
  • AWS Route 53 for the domain name services and creates a hosted zone in each AWS region that has been specified
  • AWS Certificate Manager which provides the SSL certificate for secure connection from the client to the load balancers
  • AWS ELB ( Elastic Load Balancing ) which balance all HTTPS to the web servers
  • AWS ASG ( Auto Scaling Groups ) which auto scales the Fargate web servers running on ECS based on CPU usage
  • AWS CodePipeline for the CI/CD ( Continuous Integration and Continuous Delivery )
  • AWS CodeBuild which takes changes from the respective GitHub repository and builds the React application image using Docker and updates or stores it in AWS ECR
  • AWS Lambda that updates the AWS ECS cluster service with the updated Docker image from ECR
  • AWS EventBridge which triggers the above Lambda function when a successful push has been made to the main region ECR repository

Setting up this infrastructure

Install AWS CDK

  1. Create a AWS account.

  2. Install the AWS CLI

  3. Configure your AWS account.

    aws configure
  4. Install AWS Cloud Development Kit (CDK) v2

  5. Bootstrap your environment:

    cdk bootstrap

DNS Setup

Skip this section if you do not wish to use your own domain name.

If you would like to purchase your own domain name through AWS Route53 follow this official AWS Guide.

  1. If you do not already have a hosted zone in Route53 (AWS Guide)

    1. Go to Route53
    2. If you're new to Route 53, choose Get started under DNS management.
    3. If you're already using Route 53, choose Hosted zones in the navigation pane.
    4. Choose Create hosted zone.
    5. In the Create Hosted Zone pane, enter the name of the domain that you want to route traffic for. You can also optionally enter a comment.
    6. For Type, accept the default value of Public Hosted Zone.
    7. Choose Create.
  2. Update domain name servers (AWS Guide)

    1. Go to Route53
    2. In the navigation pane, choose Registered Domains.
    3. Choose the name of the domain for which you want to edit settings.
    4. Choose Add or edit name servers.
    5. Replace the name servers with the name servers for the Route 53 hosted zone.

Deploying this infrastructure

  1. Change directory to the architecture of your choice.

  2. Configure your infrastructure with the config.yaml file.

    For the ECS CPU and Memory configuration

Demo
  1. Synthesize the CloudFormation Templates:

    cdk synth
  2. Deploy the GitHubConnection stack to connect your account to Github:

    cdk deploy GitHubConnection
  3. Wait the stack to finish before continuing.

  4. Accepting the GitHub connection

    1. Go to AWS CodeStar Connections.
    2. Choose the github-portfolio-connection-ecs connection.
    3. Click Update pending connection.
  5. Deploy the PersistentParentStack and PipelineStackECS stacks:

    cdk deploy PersistentParentStack PipelineStack
  6. Go to the AWS CodePipeline Console and wait for the PipelineStackECS pipeline to finish.

  7. Deploy the remaining stacks:

cdk deploy --all

Updating ECS configuration

  1. Update the config.yaml ecs values.

  2. Re-deploy stacks:

    cdk deploy --all

Destroying this infrastructure

If you want to destroy the stacks simply run:

cdk destroy --all --force