2

I have created a Jenkins job that invalidate the cache each time that my frontend project is deployed. The issue is that although the AWS Website display that the cache is invalidating, when the job finish, the cache isnt completly cleaned, so I need to invalidate it manually through the AWS Website...

The way to invalidate the cache automatically that I used is through aws container where I execute the following command:

  • aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths /* > output.json

The output file will contain a json where I can get differents keys: values. Two of they that I use is Id and Status. Once the invalidation was created, I another pipeline step I execute the following:

  • aws cloudfront get-invalidation --distribution-id ${DISTRIBUTION_ID} --id ${id_invalidator} > status_invalidation.json

With the previously command I quest to the API each 50 second (through a sleep 50) the status of the invalidation. When the validation return a `Status = Completed', the job is finished. This condition are inside a while loop.

Someone know why this is happened?

Carlos Andres
  • 12,740
  • 7
  • 18
  • 34
  • I don't see an issue with the approach you are trying. Were you able to confirm that this is happening only for CLI command and not doing it manually via web console for the first time? – Ashan Nov 23 '18 at 02:12
  • Hi @Ashan ! Thanks for your response. The solution was gived by Michael - sqlbot ! Thanks in all the ways!! – Carlos Andres Nov 26 '18 at 01:35

1 Answers1

6

You always have to quote expressions with the * character on the command line, to avoid local shell expansion. The correct syntax is this:

--paths '/*'

Otherwise you are trying to invalidate names based on what's in the root directory on your local filesystem (as captured by the *, expanded by the shell).

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • If you're running into issues on PowerShell try `--paths \"/*\"`. Source: https://stackoverflow.com/a/48104731/11993942 – radihuq Jan 17 '21 at 17:26