Last active
October 18, 2021 03:23
-
-
Save miguelmota/fd35d253e5b3293e042198e4dc0823fb to your computer and use it in GitHub Desktop.
AWS CodePipeline CodeBuild middleman build deploy to S3 and invalidate cloudfront cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Give CodeBuild project role access to S3 and CloudFront | |
- Set specified environment variables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.