AWS Elastic Beanstalk Deployment

This page documents deployments using the next major version dpl v2, which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Be sure to read the v2 deployment overview.

Travis CI can automatically deploy your application to Elastic Beanstalk after a successful build.

For a minimal configuration, add the following to your .travis.yml:

  provider: elasticbeanstalk
  access_key_id: <encrypted access_key_id>
  secret_access_key: <encrypted secret_access_key>
  bucket: <bucket>
  edge: true # opt in to dpl v2

Status #

Support for deployments to AWS Elastic Beanstalk is *stable**.

Known options #

Use the following options to further configure the deployment.

access_key_id AWS Access Key ID — required, secret, type: string
secret_access_key AWS Secret Key — required, secret, type: string
region AWS Region the Elastic Beanstalk app is running in — type: string, default: us-east-1
app Elastic Beanstalk application name — type: string, default: repo name
env Elastic Beanstalk environment name to be updated. — type: string
bucket Bucket name to upload app to — required, type: string, alias: bucket_name
bucket_path Location within Bucket to upload app to — type: string
description Description for the application version — type: string
label Label for the application version — type: string
zip_file The zip file that you want to deploy. If not given, a zipfile will be created from the current directory, honoring .ebignore and .gitignore. — type: string
wait_until_deployed Wait until the deployment has finished — type: boolean, requires: env
wait_until_deployed_timeout How many seconds to wait for Elastic Beanstalk deployment update. — type: integer, default: 600

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Environment variables #

All options can be given as environment variables if prefixed with AWS_ or ELASTIC_BEANSTALK_.

For example, access_key_id can be given as

  • AWS_ACCESS_KEY_ID=<access_key_id> or

Securing secrets #

Secret option values should be given as either encrypted strings in your build configuration (.travis.yml file) or environment variables in your repository settings.

Environment variables can be set on the settings page of your repository, or using travis env set:

travis env set AWS_ACCESS_KEY_ID <access_key_id>

In order to encrypt option values when adding them to your .travis.yml file use travis encrypt:

travis encrypt <access_key_id>

Or use --add to directly add it to your .travis.yml file. Note that this command has to be run in your repository’s root directory:

travis encrypt --add deploy.access_key_id <access_key_id>

Creating an application without deploying it #

To create an application without deploying it, simply exclude the env option and this will only upload the app version without deploying it to a new environment.

Controlling which files are included in the ZIP archive #

You can control which files are included in the ZIP archive you upload with .ebignore and .gitignore, as described in the AWS CLI documentation.

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #