[Solved] Unknown options: –cli-binary-format AWS CLI

If you have tried calling the AWS CLI and got the following error:

Unknown options: --cli-binary-format
Code language: plaintext (plaintext)

Then it is because you are using the AWS CLI v1 and should be using the newer AWS CLI v2.

Another error that you will see along with this is:

An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Could not parse payload into json: Unrecognized token 'eyJwYXRoIjoiJEdMAAAAIgfQo': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
Code language: plaintext (plaintext)

An example that fails on AWS CLI v1

aws lambda invoke --function-name YourFunction --cli-binary-format raw-in-base64-out --payload '{"yourKey":"yourValue"}'
Code language: Bash (bash)

How to fix this error on AWS CLI v1

aws lambda invoke --function-name YourFunction --region eu-west-1 --payload '{"yourKey":"yourValue"}' response.json
Code language: Bash (bash)

How to fix this error by Upgrading to AWS CLI v2

You can follow the guide directly to upgrade your CLI from v1 to v2 here Migrating from AWS CLI version 1 to version 2 – AWS Command Line Interface (amazon.com)

The instructions run through platform specific upgrades migrations:
AWS CLI version 2 migration instructions – AWS Command Line Interface (amazon.com)

How to check your AWS CLI version

You can check the version your aws CLI is running by typing:

aws --version
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments