AWS CLI Flashcards
Paginating results from S3/Dynamo. you want to show100 results per page to your users and minimize the number of API calls that you will use.
max-items
starting-token
page-size
To paginate results, you would use max-items with starting-token. This will return PAGES of data including the next token to use.
Page-Size Is about how many API calls AWS will make to pull data. It defaults to 1,000. (So to read 3500 rows, it would make 4 API calls). You might use this to reduce the amount of data read in one go if you are getting timeout errors.
using CLI, how do you filter attributes that get returned by dynamo?
–projection-expression
By default, all attrivutes will be returned. To reduce cost and traffic, you can specify which attributes with Projection Expression.
aws dynamodb scan –table-name UserPosts –projection-expression “user_id, content”
using CLI, how do you filter the ITEMS (rows) before they are returned to you ?
Using filter-expression and expression-attribute-values
aws dynamodb scan –table-name UserPosts –filter-expression “user_id = :u” –expression-attribute-values ‘{ “:u”: {“S”:”john123”}}’
how to assume new role with aws CLI
aws sts assume-role –role-arn
aws SQS commands with CLI
aws sqs list-queues
aws sqs send-message –queue-url https://sqs.eu-west-2.amazonaws.com/8681…. –message-body “Hello Steve”
aws sqs receive-message –queue-url https://sqs.eu-west-2.amazonaws.com/8681
aws sqs delete-message –queue-url xxxxxx –receipt-handle yyyyyy
Get details of current user with aws cli
aws sts get-caller-identity –profile besa (profile ovrrides default and picks other user)
M
make lambda call with aws cli both sync and async
aws lambda invoke –function-name demo-lambda-python –cli-binary-format raw-in-base64-out –payload ‘{“key1”: “lilly”, “key2”: “olivia”, “key3”:”jack”}’ response.json
Asycn Call
aws lambda invoke –function-name demo-lambda-python –cli-binary-format raw-in-base64-out –payload ‘{“key1”: “lilly”, “key2”: “olivia”, “key3”:”jack”}’ –invocation-type Event response.json
how to monitor EC2 instance(s) using aws cli
aws ec2 monitor-instances –instance-ids i-1234567890abcdef0 - MOnitor ec2 instance(s)