1

I'm new to bash, trying to create invalidation in the bash script by simply calling

aws cloudfront create-invalidation --distribution-id XXX --profile XXX --path /planning/index.html

Works fine in cmd but not in git bash. Must be some escape characters problem but Im not quite getting how it shoud be.

Update: Error message Im getting in bash when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths

Solved: Solved by providing cli-input-json

aws cloudfront create-invalidation --profile $PROFILE --cli-input-json "{\"DistributionId\":\"MY_DISTRIBUTION_ID\",\"InvalidationBatch\":{\"Paths\":{\"Quantity\":1,\"Items\":[\"/planning/index.html\"]},\"CallerReference\":\"$(date +%s)\"}}"```
9
  • What do you mean with "git bash" ? Commented Oct 12, 2020 at 8:54
  • I'm working on windows, so executing scripts in git bash Commented Oct 12, 2020 at 8:58
  • Im trying to escape slash character by passing --paths "/\planning/\index.html" but it is getting parsed to "//planning/index.html" Commented Oct 12, 2020 at 9:03
  • Slash is not a special character in the shell. Your code looks fine as far as Bash is concerned; probably an AWS problem. (You are backslash-escaping p and i though, not the slashes. If the code in the comment is the one you are actually having trouble with, why isn't it in the question?) Commented Oct 12, 2020 at 9:14
  • What error message are you getting? It might help to add that to the question as well. Commented Oct 12, 2020 at 9:15

1 Answer 1

2

For me this worked in git bash:

aws cloudfront create-invalidation --distribution-id XXX --path //index.html

The slash must be a double slash. It may be related to this issue: Passing windows slash (/) based parameters to a program from bash script

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.