Hi, I’m at a lose as to why my cloudfront Invalidation is not working. I’ve tried all the suggestions found on the board but to no avail.
My setup is Angular on Node hosted on S3 with Cloudfront
When utilising Circle 1.0 I had no issues invalidating Cloudfront, but now that I’ve moved to Circle 2.0 it no longer works.
The current deploy log error is as follows but as I’ve said, I’ve tried all different variations with and without --invalidation-batch to no avail
aws cloudfront create-invalidation --distribution-id abc123 --paths /* usage: aws [options] [parameters] aws: error: the following arguments are required: --invalidation-batch Exited with code 2
version: 2
jobs:
# The build job
build:
working_directory: ~/example
docker:
- image: circleci/node:latest
steps:
# Checkout the code from the branch into the working_directory
- checkout
# Log the current branch
- run:
name: Show current branch
command: echo ${CIRCLE_BRANCH}
- run:
name: Who Am i
command: whoami
- run:
name: Path
command: echo ${PATH}
# Restore local dependencies from cache
- restore_cache:
keys: dependency-cache-{{ checksum "yarn.lock" }}
# Install project dependencies
- run:
name: Install local dependencies
command: yarn install
# Cache local dependencies if they don't exist
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths: |
~/.cache/yarn
./node_modules
# Build the source code
- run:
name: Angular Build
command: yarn ng -- build
# Cache the dist folder for the deploy job
- save_cache:
key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- dist
# The deploy job
deploy:
working_directory: ~/example
docker:
- image: circleci/node:latest
steps:
# Log the current branch
- run:
name: Show current branch
command: echo ${CIRCLE_BRANCH}
# Restore cache from the build job which contains the
# dist folder that needs to be deployed
- restore_cache:
key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
# Install AWS cli
- run:
name: Install aws cli
command:
sudo apt-get -y -qq install awscli
# Set the signature version for the S3 auth
- run:
name: Setting Signature Version 4 for S3 Request Authentication
command: aws configure set default.s3.signature_version s3v4
# ACTIVATE CLOUD FRONT CLI
- run:
name: activate cloud front
command: |
aws configure set preview.cloudfront true
aws configure set preview.create-invalidation true
# Deploy to the S3 bucket corresponding to the current branch
- run:
name: Deploy to S3
command: |
if [ "${CIRCLE_BRANCH}" == "integration" ]; then
echo "Start S3 Sync"
aws s3 sync dist s3://example.com --cache-control "max-age=3153600" --exclude ".git/*" --exclude "*.sh" --exclude "node_modules/*" --region ap-southeast-2
echo "sync done "
# bash s3deploy-integration.sh
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
# bash s3deploy-master.sh
fi
# Invalidate Cloudfront
- run:
name: Invalidate Cloudfront
command: aws cloudfront create-invalidation --distribution-id ABC123 --paths /\*
workflows:
version: 2
# The build and deploy workflow
build_and_deploy:
jobs:
- build
# The deploy job will only run on the filtered branches and
# require the build job to be successful before it starts
- deploy:
requires:
- build
filters:
branches:
only:
- integration
- master