Invalidating Cloudfront Cache

As part of any deployment to websites hosted behind Amazon Cloudfront, it's useful to invalidate cache right after deployment to eliminate any cache issues. This can be accomplished with a simple job:

aws_params: &aws_params
AWS_ACCESS_KEY_ID: ((aws_access))
AWS_SECRET_ACCESS_KEY: ((aws_secret))
AWS_DEFAULT_REGION: us-west-2
jobs:
- name: invalidate-cache
plan:
- task: cloudfront-invalidate
config:
platform: linux
image_resource:
type: docker-image
source:
repository: oozie/vmware-aws
params:
<<: *aws_params
run:
path: /bin/bash
args:
- -c
- |
aws cloudfront create-invalidation \
--distribution-id E32XS6HDPKMNEI --paths "/*"