Site Tools


aws:awscli

awscli cookbook

CloudFormation
# validate json
aws cloudformation validate-template --template-body file://./cfn.json
 
# create stack
aws cloudformation create-stack --stack-name myteststack \
  --template-body file://./cfn.json \
  --parameters ParameterKey=Product,ParameterValue=dcai-cfn-product \
  ParameterKey=Application,ParameterValue=dcai-awesome-app
 
DynamoDB
# Create dynamodb instance
aws dynamodb create-table --table-name dcai-dynamodb-instance \
  --attribute-definitions AttributeName=buildID,AttributeType=S \
  AttributeName=planID,AttributeType=S \
  --key-schema AttributeName=planID,KeyType=HASH \
  AttributeName=buildID,KeyType=RANGE \
  --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
 
# Delete dynamodb instance
aws dynamodb delete-table --table-name dcai-dynamodb-instance
Kinesis
# create kinesis stream
aws --region ap-southeast-2 kinesis create-stream --stream-name dcai-kinesis-instance --shard-count 1
S3
# list buckets
aws ls
# list files in bucket
aws s3 ls --recursive --summarize --human-readable s3://bucket-name
# make a bucket
aws s3 mb s3://dcai
# remove file
aws s3 rm s3://bucketname/pathtofile.txt
# cp file
aws s3 cp ./localfile.txt s3://bucketname/pathtofile.txt
# bulk copy
aws s3 cp ./local/dir/ s3://picsbucket/ --recursive --include '*.jpg' --include '*.png' \
  --exclude '.git/*' --exclude 'node_modules/*'
EC2
# find terminated instances
aws ec2 describe-instances --filter 'Name=instance-state-name,Values=terminated'
 
aws ec2 describe-instances | jq '.Reservations[] | {O: .OwnerId, State: .Instances[0].State}'
# search amazon linux image id
aws ec2 describe-images --filters "Name=description, Values=Amazon Linux AMI 2016.03.*"\
 --query "Images[*].ImageId" --output text
 
# find all micro instances
aws ec2 describe-instances --filters "Name=instance-type,Values=t2.micro"
 
# get all public names
aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" \
--query "Reservations[].Instances[].PublicDnsName" \
--output text
aws/awscli.txt · Last modified: 2021-06-25 by dcai