I wrote a custom Wercker deploy step to invalidate CloudFront cache because it was not supported by the official s3sync step. But in Feb 24, 2015, wercker team has upgraded s3cmd to 1.5.1.2. Means that if you followed those tutorials to setup your Jekyll blog:

  1. Configure a Bucket for Website Hosting
  2. Simplify your Jekyll publishing process with wercker and Amazon S3
  3. Using CloudFront with Amazon S3

You can simply add this option and wercker will do the rest for you:

# in wercker.yml

deploy:
    steps:
        - s3sync:
            key_id: $KEY
            key_secret: $SECRET
            bucket_url: $URL
            source_dir: _site/
+           opts: --cf-invalidate

It will invalidate the path for default index (/subdir/). If you’d like to invalidate default index (/subdir/index.html) or both. Add applicable options:

  • --cf-invalidate-default-index: Will invalidate /subdir/index.html
  • --cf-no-invalidate-default-index-root: Will NOT invalidate /subdir/

Details are in s3cmd tool Usage.