The right way to run AWS CLI instructions based mostly on AWS CLI Model in Bash

If you end up having the necessities to assist each AWS CLI v1 and v2 concurrently, then you need to use the next conditional in Bash to solely run the particular model required:

AWS_VERSION=$(aws --version | gawk '{print $1}' | gawk -F/ '{print $2}' | gawk -F. '{print $1}')
if [ AWS_VERSION == "1" ]
    aws lambda invoke --function-name YourFunction --payload $(echo '{"okay":"v"}') response.json
    aws lambda invoke --function-name YourFunction --cli-binary-format raw-in-base64-out --payload '{"okay":"v"}' response.json

This may be helpful for deploying to environments the place you can’t assure the AWS CLI model put in. Similar to distributed pipelines, or buyer environments.

See also  Largest Quantity Groupings in String in Python

Leave a Reply