Deploying to AWS with Travis CI

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Travis CI doesn’t just let us automate the testing and release of our code — it can even deploy our code to production (or wherever you need it to be deployed). In this lab, we’ll take an existing Travis setup and add a stanza to deploy it to a provided Amazon S3 bucket.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the Bucket
  • Log in to the AWS Console and create a public bucket with web hosting enabled.
Encrypt Your Keys
  • Create an AWS access key.

  • Using the Travis client, encrypt your AWS access key and secret key.

Add the Deploy
  • Add the deploy stanza to the .travis.yml file, then push the changes and watch the deploy.

Additional Resources

You have finished writing a Travisfile that launches and tests your static landing page, and now you want to get it up and running by moving it to an Amazon S3 bucket. (NOTE: All resources must be premade.)

Use the following bucket policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::BUCKET-NAME/*"
            ]
        }
    ]
}

External Lab Setup

A GitHub account with Travis CI authorized needs to be used alongside this lab. While we provide the deployment environment, Travis CI is a fully hosted solution and needs to be used with your existing GitHub account.

Prior to beginning this lab, clone the contents of this repository (https://github.com/linuxacademy/content-building-travis) to your workstation, then copy the bookwebsite file to a new directory. Initialize a Git repository in this directory, and create a GitHub remote for it. Ensure Travis CI is authorized to work with the repository.

If you have taken the Building a Continuous Integration Pipeline with Travis CI course, use your existing bookwebsite setup.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?