DevOps Training
  • DevOps
  • What is DevOps
    • What DevOps Look like
    • Why DevOps Needed
    • DevOps Automation Tools
    • DevOps Principles
  • cloud computing
    • How DevOps links with Cloud Computing
    • What is cloud computing?
      • Platform as a service (PaaS)
      • Infrastructure as a service (IaaS)
      • Software as a service (SaaS)
      • Function as a Service
      • SaaS, PaaS, IaaS
  • Version Control
    • Git as Version Control
      • Setting up Remote Repo
      • Git Hooks
      • github vs gitlab vs bitbucket
      • Quick Recap Git
  • DevOps #01 Continuous Integration
    • Continuous Integration & Continuous Delivery
      • Understanding CI Tools
      • Prerequisite
      • Continuous Integration
      • CI Tools
      • Travis-CI
        • Travis CI with S3
        • Static Site Build S3
        • Beanstalk with AWS CLI
          • Elastic Beanstalk with Travis CI
        • Travis using Code Deploy EC2
          • Github and Code Deploy
          • Travis CI with Code Deploy
      • Gitlab-CI
        • CI Setup for application
        • Gitlab Runners on EC2
        • CI Integration with AWS
          • Deploying App using Gitlab CI
          • Gitlab CI with AWS S3
          • Gitlab CI with ECS
          • CI Integration with EC2
            • Update and Clean Gitlab.yml
        • Install Gitlab on EC2
      • CI/CD using Jenkins CI
        • Jenkins Build on EC2
        • Jenkins Build EC2 Ubuntu
        • Jenkins CI/CD
          • Create a Build Item
          • Create a Build Pipleine
            • Pipeline Using Docker
            • Pipeline Examples
          • Jenkins CI with S3
            • Jenkins CI - S3
          • Jenkins CI with EC2
    • Jenkins CI Cluster Mode
    • AWS Code Pipeline CI/CD
      • AWS CI/CD Tools
        • AWS Code Build
        • AWS Code Deploy to Beanstalk
        • AWS Code Deploy to EC2
        • AWS Pipeline - Example CI/CD
  • Docker
    • Docker
      • Docker for Developers
        • Install and setup
        • Docker Commands
        • Docker Images Container
        • Docker Architecture
    • Docker Demos
      • Node JS Container
    • Docker-compose
      • Using Docker Compose
      • Docker Compose Demo
  • AWS Quick Refresh
    • AWS Quick Recap - Videos
    • AWS Quick Recap
  • AWS Architecture - Lab
    • Application Deployment - 01
    • Application Deployment - 02
    • Application 3 tier Architecture
  • Basic Networking
    • Computer Networking for Beginners
      • Basic of Networking
      • Networking Protocols
      • OSI Model
      • Network address and Host address
      • Subnetting Type
    • Network Architecture
    • Networking Layers OSI Model
    • Internet protocol
      • CIDR and subnetting
        • Examples
      • AWS VPC Subnets
  • VPC and Networking
    • AWS VPC
    • VPC Demo
      • Bastion Host | Jump Server
  • AWS Components
    • AWS Components In Depth
      • AWS Storage
        • AWS EBS
        • AWS Cloudfront
        • AWS S3
      • AWS Compute
        • ECS
        • AWS VPC
          • VPC Components
        • AWS EC2
        • AWS ELB
          • Application Load balancer
            • Example
        • AWS EC2 Auto Scaling
          • Demo
        • AWS Route 53
        • AWS Lambda Serverless
          • AWS Lambda Serverless Computing
  • Assignments
    • Assignment 01-Node JS app on EC2
    • Assignment 02-Node JS with Mysql
    • Assignment-03
  • Microservices
    • Microservices Architecture
      • Docker and Docker-Compose
      • Docker-Compose Example 01
      • Docker-Compose Example 02
      • Hand-on | Building Microservices
    • Architecture Components
  • AWS ECS
    • AWS ECS
      • Introduction of ECS
Powered by GitBook
On this page

Was this helpful?

  1. DevOps #01 Continuous Integration
  2. Continuous Integration & Continuous Delivery
  3. Travis-CI
  4. Beanstalk with AWS CLI

Elastic Beanstalk with Travis CI

PreviousBeanstalk with AWS CLINextTravis using Code Deploy EC2

Last updated 5 years ago

Was this helpful?

Elastic Beanstalk is a really awesome service provided by AWS that deploys, automatically scales and provisions your applications. If you’re interested in learning more, see my previous on how to deploy a Docker container using Elastic Beanstalk! Deploying with Elastic Beanstalk is extremely easy if you use the CLI, API or management console in your AWS dashboard. But with those methods, every time you want to deploy your app, you need to manually fire up the CLI or log into your dashboard, which can be time consuming.

In this tutorial, I will show you how to add a Travis CI integration that will automatically deploy your application with Elastic Beanstalk whenever you push to your master branch on github. This integration will help you be on your way to achieving a continuous delivery model!

Prerequisites:

  1. You have an application with Elastic Beanstalk configuration set up. I assume that you are able to manually deploy to Elastic Beanstalk. Feel free to my simple Node.js and Docker app from my previous tutorial that has the Travis CI configuration set up to follow along with. You are not required to use Node.js or Docker, they are just the technologies I used in this example.

  2. Your app should be on github since in this tutorial, we will be using the github Travis CI configuration.

  3. Set up your favorite text editor. I like to use

Part 1: Add Travis CI integration to your Application

Travis CI as service now not available on github you can just directly go to

The next thing we need to do is add a .travis.yml file that tells Travis CI how to build our application. First we will add an extremely simple .travis.yml and test that our builds get triggered. Add a .travis.yml file in your repo’s top level directory. Below is the starter travis config file that I added. The Docker service is not required if you are not using Docker. If you are not using Node.js, you’re .travis.yml will need to have the correct configurations for the language that you are using.

Now commit and push your .travis.yml file. You can monitor that the build has started by navigating to the repo on the Travis CI page. Below is an example of a build in progress:

Once your build passes, we can add the Elastic Beanstalk configuration to deploy your application automatically

Part 2: Integrate Elastic Beanstalk with your Travis CI build

Now we can add the Elastic Beanstalk configuration to our .travis.yml. Append the following configuration below to your .travis.yml

Before pushing the updated .travis.yml configuration there are a few things that need to be done:

  1. Edit the region, app, env, and bucket_name to match the configurations of your app. Bucket_name corresponds to the S3 bucked that your source code is added to every time you deploy your app.

  2. Change the “on branch” configuration to match the branch that you would like to use as the “deploy” branch. I use master in this example, so that if you push to master, there will be a deployment, and no deployment on any other branch. If you omit this section, your app will be deployed every time you push code to any branch.

  3. For the access key id and secret access key, I added environment variables to my repo’s Travis settings within the Travis UI and reference them in the .travis.yml to prevent my access keys from being pushed to source control. You can get your access keys by visiting the IAM tab in your AWS management console and you either need to create a new user or use the keys from an existing user that you have saved. Add these keys as secure environment variables to your repo’s settings in the Travis CI dashboard.

  4. In this use-case user should have access to both S3 and elastic beanstalk using IAM we can set permissions

Now push your updated .travis.yml file and wait for the build to start!

warnings_are_errors: false
language: node_js
node_js:
  - '10'
  - node
install:
- yarn
script:
- CI=false npm run test
deploy:
  provider: elasticbeanstalk
  access_key_id: $AWS_ACCESS_ID
  secret_access_key: $AWS_SECRET_ID
  region: us-west-2
  app: "CCCCCC"
  env: "CCCCCC-env"
  bucket_name: "XXXXXXXXXXXXXXX"
  on:
    branch: s3-elasticbeanstalk-node

No Lets manually create app on elastic beanstalk

Once application is created from AWS console we have update few things

Important things to update configuration - Select the Configuration option on the left side menu within your app in the EB console and click the little “Modify” button within the “Software” box:

Now you’ll see that there’s an empty field called “Node command”. All you have to do is enter “npm start” as the start command and hit the “Apply configuration” button on the top right corner.

Now we can update our travis.yml and put correct application name and environment name with s3 bucket name, Now lets push the code to travis

Once your build finishes and succeeds, the log should show some information about your application’s deployment:

If you navigate to your Elastic Beanstalk dashboard page and view your application, it should say that the application is being updated and should complete updating after a few minutes.

Closing Thoughts:

With a few button clicks and lines of code, we have added automatic deployment to our Elastic Beanstalk environment! Overall, Travis CI makes it super easy to add Continuous Integration/Continuous Deployment to your application’s development process by providing cool integrations like Elastic Beanstalk that allow you to deploy automatically. This is just one simple example using Travis CI

Now that we’ve added Travis to the repo, sign into . Add your new repository by clicking on the “+” sign in your list of repos. Make sure you sync your github account if your repo is not visible in the list. Find your repo, and then flick the repository switch on. Now Travis has been enabled! Now every time you push code to your repo, a Travis build will be triggered

https://travis-ci.org/
tutorial
clone
Visual Studio Code
LogoHomepage | Travis CI – Start building today!Travis CI
LogoTravis CI - Test and Deploy Your Code with Confidence