AWS CodeDeploy: files created in before_deploy stage are not copied

I’m using the before_deploy stage to create a config file with interpolated environment variables. I have confirmed that this file exists in the before_deploy build by reading its contents using cat.

before_deploy:
- envsubst < "pisces/config.py.deploy" > "pisces/deploy_config.py"

However, this file never makes it to the deployment environment. I’ve looked at the bundles that CodeDeploy downloads, and the file is not present there.

I have tried this on dpl v1 with the skip_cleanup key set to true

deploy:
  skip_cleanup: true
  provider: codedeploy
  revision_type: github
  access_key_id: $AWS_ACCESS_KEY
  secret_access_key: $AWS_SECRET_KEY
  application: pisces
  deployment_group: PiscesDevelopment
  region: us-east-1
  on:
    repo: RockefellerArchiveCenter/pisces
    branch: development

And I’ve tried it on dpl v2 as well:

deploy:
  provider: codedeploy
  edge: true
  revision_type: github
  access_key_id: $AWS_ACCESS_KEY
  secret_access_key: $AWS_SECRET_KEY
  application: pisces
  deployment_group: PiscesDevelopment
  region: us-east-1
  on:
    repo: RockefellerArchiveCenter/pisces
    branch: development

I’m getting the same result in both cases.

I’m wondering if this is a function of using a github revision_type? Are am I missing something else?

Answering my own question: this is more of an AWS CodeDeploy issue than a Travis CI one. When deployments are triggered using the github revision type they are tied to a specific commit. Since the files generated in the before_build stage are not versioned (which is by design, since they contain sensitive information) they are never pulled down by CodeDeploy.

I’d suggest adding a line in the Travis CodeDeploy provider docs which notes that the skip_cleanup/cleanup keys will have no effect for the github revision type.

We welcome your suggestions for improving the docs! (There is a convenient “Edit” button on the top right corner!)

1 Like
Imprint