AWS OpsWorks 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.
Travis CI can automatically deploy your AWS OpsWorks application after a successful build.
For a minimal configuration, add the following to your
deploy: provider: opsworks access_key_id: <encrypted access_key_id> secret_access_key: <encrypted secret_access_key> app_id: <app_id> edge: true # opt in to dpl v2
You can obtain your AWS Access Key Id and your AWS Secret Access Key from here.
region defaults to
us-east-1. If your application is located in a different
region you will see an error
Unable to find app.
Support for deployments to AWS OpsWorks is *stable**.
Known options #
Use the following options to further configure the deployment.
||AWS access key id — required, secret, type: string|
||AWS secret key — required, secret, type: string|
||The app id — required, type: string|
||AWS region — type: string, default:
||An instance id — type: string or array of strings|
||A layer id — type: string or array of strings|
||Migrate the database. — type: boolean|
||Wait until the app is deployed and return the deployment status. — type: boolean|
||When wait-until-deployed and updated-on-success are both not given, application source is updated to the current SHA. Ignored when wait-until-deployed is not given. — type: boolean, alias:
||Custom json options override (overwrites default configuration) — type: string|
Shared options #
||Clean up build artifacts from the Git working directory before the deployment — type: boolean|
||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
access_key_id can be given as
Securing secrets #
Secret option values should be given as either encrypted strings in your build
.travis.yml file) or environment variables in your repository
Environment variables can be set on the settings page of your repository, or
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 encrypt <access_key_id>
--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>
Migrate the Database #
If you want to migrate your rails database on travis to AWS OpsWorks, add the
deploy: provider: opsworks # ⋮ migrate: true
Waiting for Deployments #
By default, the build will continue immediately after triggering an OpsWorks
deploy. To wait for the deploy to complete, use the
deploy: provider: opsworks # ⋮ wait_until_deployed: true
Travis CI will wait up to 10 minutes for the deploy to complete, and log whether it succeeded.
Updating App Settings after successful Deployments #
By default the deploy from Travis CI triggers a deployment on OpsWorks but does
not touch any other configuration. To also update the revision in App Settings
update_app_on_success option. In addition you have to set the
deploy: provider: opsworks # ⋮ wait-until-deployed: true update-app-on-success: true
Travis CI will wait until the deployment returns successful and only then update the revision in App Settings.
Pull Requests #
Note that pull request builds skip the deployment step altogether.