AWS Elastic Beanstalk Deployment

This page documents deployments using dpl v1 which currently is the default version. The next major version dpl v2 will be released soon, and we recommend starting to use it. Please see our blog post for details. dpl v2 documentation can be found here.

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

To deploy to AWS Elastic Beanstalk add the following to your .travis.yml:

  • access-key-id: Encrypted AWS Access Key ID, obtained from your AWS Console.
  • secret-access-key: Encrypted AWS Secret Key, obtained from your AWS Console.
  • region: must be the region the Elastic Beanstalk application is running on, for example us-east-1.
  • app: Application name.
  • env: Elastic Beanstalk environment the application will be deployed to.
  • bucket_name: Bucket name to upload the code of your app to. Elastic Beanstalk will create and deploy an application version from the source bundle in this Amazon S3 bucket.
  provider: elasticbeanstalk
    secure: "Encrypted <access-key-id>="
    secure: "Encypted <secret-access-key>="
  region: "us-east-1"
  app: "example-app-name"
  env: "example-app-environment"
  bucket_name: "the-target-S3-bucket"

Alternatively, use the Travis CI command line setup tool to add the deployment travis setup elasticbeanstalk.

Creating an application without deploying it #

To create an application without deploying it, add only_create_app_version: "true" to your .travis.yml.

Optional settings #

  • zip_file: The zip file to deploy. You also need to set skip_cleanup to prevent Travis CI deleting the zip file at the end of the build. If this is left unspecified, a zip file will be created from all the files that are part of the repository under test (determined with git ls-files).
  • bucket_path: Location within Bucket to upload app to.

Environment variables #

The following environment variables are available:

  • ELASTIC_BEANSTALK_ENV: Used if the env key is not set in your .travis.yml.
  • ELASTIC_BEANSTALK_LABEL: Label name of the new version.
  • ELASTIC_BEANSTALK_DESCRIPTION: Description of the new version. Defaults to the last commit message.

Running commands before and after deploy #

Sometimes you want to run commands before or after deploying. You can use the before_deploy and after_deploy stages for this. These will only be triggered if Travis CI is actually deploying.

before_deploy: "echo 'ready?'"
  - ./
  - ./