Skip to content

psgabriel/terraform_beanstalk_container_node_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized Node.js App on AWS Elastic Beanstalk with Continous Integration Strategy

Terraform and Jenkins scripts to setup AWS Elastic Beanstalk with dockerized load-balanced NodeJS app.

What these scripts do?

  • Build a Docker image with Node APP;
  • Publish a Docker image on Docker Registry;
  • Create a Clound Computing environment on Amazon Web Server;
  • Store Elastic Beanstalk environment informations on AWS S3;
  • Setup the AWS Elastic Beanstalk Application with NodeJS, Elastic Loadbalancer to forward HTTP

Project repository

https://github.com/psgabriel/terraform_beanstalk_container_node_test

Node APP Sample

https://github.com/nodejs/nodejs.org.git


❗ General requirements:

  • Host with Linux Operational System;
  • Internet Access;
  • Wget, Git, Docker, Docker-compose, Terraform and Jenkins installed;
  • Intermediate knowledge on System Integrations, Cloud Computing, Application Deployment and basic understanding about Continous Integration.

Proposed scenario

Item Resource Chain Resource
Docker Image Build node_stg:latest
Docker Image Publish psgabriel/node_stg
AWS static resources VPC, IAM Security Group, Subnet, Internet Gateway, Route
AWS dinamic resources Beanstalk, S3 Autoscaling and Loadbalancer Policies

Beanstalk Environment:

  • Instance Type: t2.micro
  • AWS Region: us-east-1
  • Type: Loadbalanced
  • Autoscalling Instances: min 2
  • Autoscalling Instances: max 4
  • Autoscalling Threshold: NetworkIn > 18000000 bytes / 5min
  • Solution Stack: 64bit Amazon Linux 2018.03 v2.12.14 running Docker 18.06.1-ce
  • Deployment Policies: Health, Immutable or Rolling

Macro steps for manual process:

Without automation or Continous Integration

1) Build a new Docker image:

2) Publish the Docker image to a private or public repository:

In this example it was used the Docker Hub repository, but you can choose AWS or Azure Registry, Artifactory, Nexus, etc.

  • Dockerized Node App on Docker Hub:
  • Image of Dockerhub

3) Deploy of AWS Static Resources:

  • Initialize, Plan and Apply the main resources which will be used over APP life circle.
  • Image of Terraform sta apply

4) Deploy of AWS Dinamic Resources:

  • In this step, the Terraform will create a new Beanstalk environment to run dockerized Node APP.
  • Image of Terraform din apply
Note that the CNAME is set with the Web Server Beanstalk URL from Node APP environment

Continous Integration with Jenkins:

Automatic process to build, publish and deploy AWS resources with Jenkins.

  • Image of Jenkins Pipe

1) Create a new pipeline project

2) Run the job

  • Some options to customize the jorney
  • Image of Jenkins Run1

3) Check job status

Image of Jenkins Result
Jenkins stages:

  • Checkout SCM - Jenkinsfile read
  • Get App - Get NodeAPP Source
  • Docker Image Build - Prepare dockerized image
  • Docker Hub Publish - Upload Docker image to Dockerhub
  • Terraform Init - Terraform initilization
  • Terraform Plan - Prepare detailed AWS information about Beanstalk
  • AWS Resource buil - Beanstalk Contruction
  • AWS Destroy - Beanstalk delete, if necessary
  • Post Actions - Slack notification for Successed or Failed jobs

4) Beanstalk Up

  • The Beanstalk Environment URL will be sent to Slack channel.
CNAME: node-stg-blue.6xrmtp9nxv.us-east-1.elasticbeanstalk.com
  • Image of Slack Notification

5) AWS Beanstalk Console

  • Image of Beanstalk App
  • Image of Beanstalk Env

6) Full deploy and Node APP accessible by internet browser

  • Image of Beanstalk App

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published