Travis

AWS Elastic Beanstalk Deployment

This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig 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.
deploy:
  provider: elasticbeanstalk
  access_key_id:
    secure: "Encrypted <access-key-id>="
  secret_access_key:
    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.

Create 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 from 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.

Run Commands Before or 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?'"
deploy:
  ..
after_deploy:
  - ./after_deploy_1.sh
  - ./after_deploy_2.sh