Is it possible to call AWS CloundFront API with CURL? I would like to trigger an invalidation without installing much dependency. But I'm unable to make a simple GET request to the API:
curl -v -X GET \
-H "Date: $(date -R)" \
-H "Authorization: AWS ${CLOUDFRONT_ACCESS_KEY}:$(echo -en ${CLOUDFRONT_ACCESS_KEY} | openssl sha1 -hmac ${CLOUDFRONT_SECRET_ACCESS_KEY} -binary | base64)" \
https://cloudfront.amazonaws.com/2020-05-31/distribution/EMC3WW4JXXXXX/invalidation/IXMUICGG7L77A
Results
<?xml version="1.0" encoding="UTF-8"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
<Error>
<Type>Sender</Type>
<Code>IncompleteSignature</Code>
<Message>Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization=AWS AKIAJG77PBXLMN5YQI7A:K62YyDlWiVf/yr44YSs7BbsQYDQ=</Message>
</Error>
<RequestId>f9e5b7de-bce6-4bfd-951e-2986ae5bc1a3</RequestId>
</ErrorResponse>
You can take a look at Signing AWS requests with Signature Version 4 for signing the request.
Plus the invalidation API call needs more params for making the call as per the documentation
I usually keep this handy s3-rest-api-with-curl