August 6, 2018

awscli commands

Amazon Web Services Command Line Interface (AWSCLI)

Installing aws cli in Python:
    pip install awscli
    pip install awscli --upgrade --user

aws [options] <command> <subcommand> [parameters]

aws --version
aws-cli/1.15.4 Python/3.6.3 Darwin/16.7.0 botocore/1.10.4

aws help
aws ec2 help
aws autoscaling create-auto-scaling-group help

aws configure
$ aws configure --profile user2

output format
json
text
table
export AWS_DEFAULT_OUTPUT="text"

$ aws s3 ls
aws s3 ls s3://satya-sparks/NYC_Parking_Tickets/
aws s3 ls s3://satya-sparks --recursive --human-readable --summarize
aws s3 ls s3://mybucket --recursive
aws s3 cp mnist.csv s3://thirumani-bucket
aws s3 cp /tmp/dir/ s3://thirumani-bucket/ --recursive
aws s3 cp /tmp/my_dir/ s3://thirumani-bucket/ --recursive --exclude "*" --include "*.jpg"
sudo aws s3 cp $OUTDIR.tar.gz s3://sr-cache/perfResults/$DATE_DIR/$RUN_ID/
aws s3 cp -R <dir_name>
time aws s3 cp --recursive --quiet . s3://test_bucket/test_smallfiles/
aws s3 cp s3://mybucket/test.txt test_local.txt
aws s3 cp s3://srcbucket/ s3://destbucket/ --recursive --exclude "a*" --exclude "b*"
aws s3 cp s3://mybucket/test.txt s3://mybucket/test2.txt --acl public-read-write
aws s3 cp file.txt s3://mybucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=emailaddress=user@example.com
aws s3 mv test.txt s3://mybucket/test2.txt
aws s3 mv s3://mybucket/test.txt s3://mybucket/test2.txt
aws s3 mv s3://mybucket/ s3://mybucket2/ --recursive --exclude "mybucket/another/*"
aws s3 rm s3://mybucket/test2.txt
aws s3 rm s3://mybucket --recursive
aws s3 mb s3://mybucket # make bucket
aws s3 mb s3://mybucket --region us-west-1
aws s3 rb s3://mybucket # remove bucket
aws s3 rb s3://bucket-name --force
aws s3 sync . s3://mybucket
time aws s3 sync --quiet . s3://test-bucket/test_randfiles/
aws s3 sync s3://mybucket s3://mybucket2
aws s3 website s3://my-bucket/ --index-document index.html --error-document error.html
aws s3api head-object --bucket test-bucket --key test_bigfiles/bigfile

$ aws ec2 start-instances --instance-ids i-X13836c
aws ec2 stop-instances --instance-ids i-X13836c
aws ec2 terminate-instances --instance-ids i-X13836c
$ aws ec2 describe-instances
aws ec2 describe-instances --filter Name=instance-type,Values=t2.nano
aws ec2 describe-instances --filters Name=instance-state-name,Values=stopped  --region  eu-west-1  --output json  |  jq  -r  .Reservations[].Instances[] .StateReason.Message
aws ec2 describe-instances --filters "Name=tag:Type,Values=Build" \
  --query "Reservations[0].Instances[0].PublicDnsName" | sed 's/"\(.*\)"/http:\/\/\1\/manage/'

aws ec2 run-instances --image-id ami-785bae10 --count 1 --instance-type t2.micro --key-name newpair.pem --security-group new-sg
aws ec2 delete-vpc --vpc-id vpc-a01106c2
aws ec2 describe-key-pairs
aws ec2 describe-key-pairs --key-name MyKeyPair
aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial' --output text > MyKeyPair.pem
aws ec2 create-key-pair --key-name newpair.pem
aws ec2 delete-key-pair --key-name MyKeyPair
aws ec2 describe-tags --output table
aws ec2 describe-spot-price-history help
aws ec2 create-security-group --group-name my-sg --description "My security group"
aws ec2 describe-vpcs --region us-west-2
aws ec2 describe-vpcs --region us-west-2 --filter "Name=tag:Name,Values=Web VPC"
aws ec2 describe-vpc-attribute --region us-west-2 --attribute enableDnsHostnames --vpc-id vpc-24be405c

aws emr add-steps --cluster-id j-XXXXXXXX --steps file://./step.json
aws emr add-steps --cluster-id j-XXXXXXXX --steps Type=IMPALA,Name='Impala program',ActionOnFailure=CONTINUE,Args=--impala-script,s3://myimpala/input,--console-output-path,s3://myimpala/output
aws emr list-steps --cluster-id j-3SD91U2E1L2QX
aws emr create-cluster --ami-version=3.3.0 --applications Name=Hue Name=Hive Name=Pig --use-default-roles --ec2-attributes KeyName=myKey --instance-groups \
  InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m3.xlarge InstanceGroupType=CORE,InstanceCount=2,InstanceType=m1.large

aws iam create-user --user-name Satya
aws iam create-group --group-name SysAdmin
aws iam add-user-to-group --group-name SysAdmin --user-name Satya
aws iam list-users
aws iam list-users --output table
aws iam list-users --query 'Users[*].[UserName,CreateDate]'
aws iam list-users --query 'Users[*].{Name:UserName,CreateDate:CreateDate}'
aws iam list-groups-for-user --user-name Satya
aws iam list-groups
aws iam get-user-policy --user-name myuser --policy-name mypolicy
aws iam put-group-policy --group-name SysAdmin --policy-name admin-policy --policy-document file://sytem_admin_policy_doc.json
aws iam list-group-policies --group-name SysAdmin
aws iam delete-group-policy --group-name SysAdmin --policy-name admin-policy
aws iam remove-user-from-group --user-name myuser --group-name mygroup
aws iam delete-group --group-name SysAdmin

aws rekognition detect-labels --image "S3Object={Bucket=photo-collection,Name=photo.jpg}" --region us-west-2

aws dynamodb list-tables
aws dynamodb scan --table-name clients_table
aws dynamodb delete-table --table-name clients_table

aws rds create-db-instance \
    --engine MySQL \
    --db-instance-identifier mydbinstance \
    --allocated-storage 20 \
    --db-instance-class db.m1.small \
    --db-security-groups mydbsecuritygroup \
    --db-subnet-group mydbsubnetgroup \
    --master-username masterawsuser \
    --master-user-password masteruserpassword \
    --backup-retention-period 3
aws rds create-db-instance ^
    --engine oracle-se2 ^
    --db-instance-identifier oradbinstance ^
    --allocated-storage 40 ^
    --db-instance-class db.t2.small ^
    --db-security-groups mydbsecuritygroup ^
    --db-subnet-group mydbsubnetgroup ^
    --master-username masterawsuser ^
    --master-user-password masteruserpassword ^
    --backup-retention-period 4
aws rds describe-db-instances
aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --backup-retention-period 7 \
    --no-auto-minor-version-upgrade \
    --no-apply-immediately
aws rds modify-db-instance ^
    --db-instance-identifier mydbinstance ^
    --backup-retention-period 7 ^
    --auto-minor-version-upgrade ^
    --apply-immediately
aws rds download-db-log-file-portion --db-instance-identifier mydbinstance --log-file-name trace/sqlnet-parameters --output text
aws rds modify-db-instance \
    --db-instance-identifier <oradbinstance> \
    --engine-version <12.1.0.2.v10> \
    --option-group-name <default:oracle-ee-12-1> \
    --db-parameter-group-name <default.oracle-ee-12.1> \
    --allow-major-version-upgrade \
    --no-apply-immediately
aws rds modify-db-snapshot --db-snapshot-identifier <mydbsnapshot> --engine-version <11.2.0.4.v12>  --option-group-name <default:oracle-se1-11-2>

Related Articles:

No comments:

Post a Comment