Coder Social home page Coder Social logo

pawelmahooana / meanstack_with_atlas_on_aws_eb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mongodb-partners/meanstack_with_atlas_on_aws_eb

0.0 0.0 0.0 2.12 MB

Sample MEAN Stack application with Atlas as it's backend deployed using AWS Elastic Beanstalk

TypeScript 92.75% CSS 0.37% HTML 3.48% Dockerfile 3.41%

meanstack_with_atlas_on_aws_eb's Introduction

Application modernization with MongoDB Atlas and AWS Elastic Beanstalk

Introduction:

This is a technical repo to demonstrate the application deployment using MongoDB Atlas and AWS Elastic Beanstalk. This tutorial is intended for those who want to

  1. Have a rapid application deployment
  2. Test out the features of an application
  3. Fail fast in their development cycle
  4. Want to try out the AWS Elastic Beanstalk and MongoDB Atlas

MongoDB Atlas is an all-purpose database having features like Document Model, Geo-spatial, Time-series, hybrid deployment, and multi-cloud services. It evolved as a "Developer Data Platform", intended to reduce the developers' workload on the development and management of the database environment. It also provides a free tier to test out the application/database features.

AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.

Architecture Diagram:

image

Step-by-Step Instruction for Deployment:

Step1: Set up the MongoDB Atlas cluster

Please follow the link to setup a free cluster in MongoDB Atlas

Configure the database for network security and access.

Step2: Set up the Elastic Beanstalk CLI

Set up the Elastic Beanstalk cli based on your Operating System using the link

Step3: Set up the AWS Elastic Beanstalk environment

a. Git Clone the code from Repo

     git clone https://github.com/mongodb-partners/MEANStack_with_Atlas_on_AWS_EB.git

b. Select database parameters in .env file and uncomment the line.(MEANSTACKwithAtlasonAWSEB --> partner-eb-meanstack-atlas --> server --> .env)

Refer the link for getting the MongoDB Atlas connection string

c. Set up the Elastic Beanstalk initialization parameters through eb init command

     cd code/partner-eb-meanstack-atlas
     
     eb init

Parameters for eb init:

a) Select a default region : 1 [ select the region in which you want to deploy the Elastic Beanstalk and note it down for future reference]

b) Select an application to use : Create new Application

Enter the application name : Select the default option.

c) It appears you are using Node.js. Is this correct?: "N"

d) Select a platform : 3) Docker

e) Select a platform branch. : default [ 1) Docker running on 64bit Amazon Linux 2)]

f) Cannot setup CodeCommit because there is no Source Control setup, continuing with initialization Do you want to set up SSH for your instances? : default [Y]

g) Select a keypair. : default

d. Create the environment with 'eb create'.

     eb create --vpc

Note: if you want to use the default vpc or not using private link for MongoDB Atlas, use only "eb create".

a) Enter Environment Name : default [partner-eb-meanstack-atlas-dev]

b) Enter DNS CNAME prefix : default [partner-eb-meanstack-atlas-dev]

CNAME should be unique. if it gives an option on account of duplicate, select the default option suggested.

Copy and paste the DNS CNAME selected to the code as the private URL. Location: "client --> src --> app --> employee.service.ts (line 10)"

Ensure the CNAME selected and Private URL server names are the same.

Also ensure the region in the URL to updated to the region selected during eb init.

c) Enter the VPC ID: "Enter the VPCID to which the privatelink is created in MongoDB Atlas cluster"

d) Do you want to associate a public IP address? (Y/n): default

e) Enter a comma-separated list of Amazon EC2 subnets: enter the public subnets as comma separated

f) Enter a comma-separated list of Amazon ELB subnets: enter the public subnets as comma separated

g) Do you want the load balancer to be public? (Select no for internal) (Y/n):

h) Enter a comma-separated list of Amazon VPC security groups:

i) Select a load balancer type : default [application]

optional parameter:

Your account has one or more sharable load balancers. Would you like your new environment to use a shared load balancer? (y/N): default

j) Would you like to enable Spot Fleet requests for this environment? (y/N): default [N]

Refer the below screenshot for further details

image

k) Ensure the successful creation of the environment. It will take minimum 10mins to create the environment. The Health status will be initiall "Green" and then change to "Severe" , when the loadbalancer started to validate the backend. This is the normal flow.

image

l) Update the configuration parameters for Loadbalancer in the below sequence (only)

a. update the Processes - deafult : Change the port to 8000

b. Add a new process for the backend with port 5200 and HTTP code to 200,404

c. insert a new listener for the backend process created.

m) Ensure the configuration changes are applied successfully

Step4: Test the application

Before testing the application, ensure the security group created by "eb create" command is opened for the port 80. This will ensure the health check is green

The endpoint of the application is displayed in the elastic beanstalk environment. ex: partner-eb-meanstack-atlas-dev2.us-east-1.elasticbeanstalk.com

Test the application for CRUD operations and ensure the data are reflected in MongoDB Atlas documents

Troubleshoot

Errors:

a) The current user does not have the correct permissions. Reason: Operation Denied. The security token included in the request is invalid.

b) ebcli.lib.aws : Error while contacting Elastic Beanstalk Service ERROR: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

Steps:

a) Verify the AWS profile is set.

b) remove the folder .elasticbeanstalk (in partner-eb-meanstack-atlas directory) and restart the steps from begining.

To redeploy the solution:

     ebs deploy

Logs: image

Summary:

Any containerized application can be deployed within no time using this template. Please check out the Application Modernization with Fargate to have similar deployments on AWS Fargate

Pls share your feedback/queries to [email protected]

meanstack_with_atlas_on_aws_eb's People

Contributors

babusrinivasan76 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.