TLDRBins TLDRBins / AWS


Usage Tips:

  • Click on a keyword to enable inline editing.
  • Click inside a code block to copy (excludes comments).
  • Use the button to view examples.
  • Click outside to collapse all examples.

Setup

# Install awscli sudo apt install awscli
Sample Output: TO-DO
# Set config aws configure
Sample Output: TO-DO
AWS Access Key ID [None]: test AWS Secret Access Key [None]: test Default region name [None]: test Default output format [None]:
Sample Output: TO-DO

Default AWS Credential Location

~/.aws/credentials
Sample Output: TO-DO

AWS Services

# List buckets aws s3 --endpoint-url <TARGET> ls
Sample Output: TO-DO
# List bucket aws s3 --endpoint-url <TARGET> ls s3://<BUCKET_NAME>
Sample Output: TO-DO
# Upload to bucket aws s3 --endpoint-url <TARGET> cp <FILE> s3://<BUCKET_NAME>/<FILE>
Sample Output: TO-DO
# List tables aws --endpoint-url <TARGET> dynamodb list-tables
Sample Output: TO-DO
# Dump table aws --endpoint-url <TARGET> dynamodb scan --table-name <TABLE_NAME>
Sample Output: TO-DO
# Create table (e.g. with column 'title' and 'content') aws --endpoint-url <TARGET> dynamodb create-table --table-name <TABLE_NAME> --attribute-definitions AttributeName=title,AttributeType=S AttributeName=content,AttributeType=S --key-schema AttributeName=title,KeyType=HASH AttributeName=content,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
Sample Output: TO-DO
# Add item to table (e.g. with column 'title' and 'content') aws --endpoint-url <TARGET> dynamodb put-item --table-name <TABLE_NAME> --item '{"title":{"S":"<TITLE>"},"content":{"S":"<CONTENT>"}}'
Sample Output: TO-DO

Basic

# List functions aws lambda list-functions --endpoint-url <TARGET>
Sample Output: TO-DO
# Check a function aws lambda get-function --function-name=<FUNC_NAME> --endpoint-url <TARGET>
Sample Output: TO-DO

Create a function (e.g. NodeJS)

exports.handler = async function(event, context) { console.log("EVENT: \n" + JSON.stringify(event, null, 2)) return context.logStreamName }
Sample Output: TO-DO

zip index.zip index.js
Sample Output: TO-DO
# Create a function aws lambda create-function --function-name <FUNC_NAME> --zip-file fileb://index.zip --role arn:aws:iam::123456789012:role/lambda-role --endpoint-url <TARGET> --handler index.handler --runtime nodejs12.x
Sample Output: TO-DO
# Invoke function test aws lambda invoke --function-name <FUNC_NAME> --endpoint-url <TARGET> result.json
Sample Output: TO-DO
# Check result cat result.json
Sample Output: TO-DO