Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active October 18, 2021 03:23
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save miguelmota/fd35d253e5b3293e042198e4dc0823fb to your computer and use it in GitHub Desktop.
Save miguelmota/fd35d253e5b3293e042198e4dc0823fb to your computer and use it in GitHub Desktop.
AWS CodePipeline CodeBuild middleman build deploy to S3 and invalidate cloudfront cache
version: 0.1
phases:
install:
commands:
- apt-get update
- apt-get install nodejs -y
- gem install bundler
- gem install middleman
pre_build:
commands:
- bundle install
build:
commands:
- middleman build
post_build:
commands:
- aws s3 sync build/ "s3://${BUCKET_NAME}" --acl=public-read --delete
- aws cloudfront create-invalidation --distribution-id "${DISTRIBUTION_ID}" --paths /index.html /* /fonts/* /images/* /javascripts/* /stylesheets/* /favicon.ico
- Give CodeBuild project role access to S3 and CloudFront
- Set specified environment variables
@slavafomin
Copy link

You should put invalidation paths in quotes. Also, the "/*" path would invalidate everything in the cache, so there is no need to specify other paths along with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment