AWS CLI + Cloudfront Invalidations

I’m working on CI/CD pipeline for a set of static assets, and am getting pretty close, but I’m running into an issue with awscli that I’m a bit lost on:

I’m using the AWS CLI to sync my built changes with a specific S3 bucket (which is cached+served via CloudFront), and am then attempting to create a CF invalidation so that the latest version is made available immediately.

When I attempt to run the following:

aws cloudfront create-invalidation --distribution-id <MY_DIST_ID> --paths <PATHS_TO_INVALIDATE>

I get the following error:

aws: error: the following arguments are required: --invalidation-batch

Per the Cloudfront CLI docs, paths should be acceptable. After some largely unsuccessful internet sleuthing, I stumbled upon this Github comment that suggests to me that I’m running an out-of-date version of the awscli.

This hunch is further compounded by the fact that the CLI warns me that the cloudfront tool is a preview only tool, and requires me to set preview.cloudfront true to use.

Is the Docker image I’m using (circleci/node:6.10-browsers) out of date? Even an apt-get update didn’t seem to resolve this, so I’m out of ideas. Any help would be greatly appreciated.

Are you installing the awscli yourself? I just grabbed that image and running aws inside of it tells me that the command is not found.

Thanks @levlaz, I should’ve mentioned that; yes, I am installing the awscli myself. I’ve attempted to apt-get update beforehand, but to no avail. Here is how I am installing it myself:

- run:
    name: Install aws cli
    command: |
      sudo apt-get update
      sudo apt-get -y -qq install awscli
1 Like

I would not install it with apt. The default image is Debian and its “so stable that it hurts” :wink:

Can you install awscli with pip instead?

sudo apt-get install python-dev python-pip
sudo pip install awscli

This should grab the latest version. , I see:

circleci@907f943edb29:/opt$ aws --version
aws-cli/1.14.16 Python/2.7.9 Linux/4.9.49-moby botocore/1.8.20
2 Likes

That did it! Thanks @levlaz! “so stable it hurts” indeed :laughing:

2 Likes