Skip to content

Instantly share code, notes, and snippets.

@dankochetov
Last active October 28, 2019 15:28
Show Gist options
  • Save dankochetov/de1ee8b1fadd1e6add1ba70ea881b28c to your computer and use it in GitHub Desktop.
Save dankochetov/de1ee8b1fadd1e6add1ba70ea881b28c to your computer and use it in GitHub Desktop.
Deploy static website to S3 using CodeBuild
version: 0.2
run-as: root
phases:
pre_build:
commands:
- npm install
build:
commands:
- npm run build:prod
post_build:
commands:
- aws s3 sync dist/ "s3://${BUCKET_NAME}" --acl=public-read --delete
- aws s3api copy-object --copy-source ${BUCKET_NAME}/index.html --bucket ${BUCKET_NAME} --key index.html --metadata-directive REPLACE --cache-control "max-age=0" --content-type "text/html" --acl public-read
- aws cloudfront create-invalidation --distribution-id "${DISTRIBUTION_ID}" --paths /\*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment