AWS Classroom Series – 28/Nov/2019

AWS CLI Setup

  • Install AWS Cli. Refer Here
  • Chocolatey: choco install awscli -y
  • Create an IAM User by following instructions from here
aws configure

# Enter Access Key, Secret Key and Region

S3 CLI

S3 CLI

  • Available commands

    • cp => copy
    • ls => list
    • mb => make bucket
    • mv => move
    • rb => remove bucket
    • rm => remove
    • sync => sync source and destination
  • aws cli syntax

aws s3 <s3 command> --param1 value 
  • s3 bucket uri syntax: s3://<bucketname>

Examples

  • Create bucket with name qts3bucketfromcli
aws s3 mb s3://qts3bucketfromcli

Exercise using AWS CLI

  1. Create any s3 bucket
aws s3 mb s3://qts3fortesting-1
  1. Copy a file from local machine to aws s3 bucket
aws s3 cp '.\Advanced Agile Material.docx' s3://qts3fortesting-1
  1. Copy a folder from local machine to aws s3 bucket
aws s3 cp --recursive .\ec2\ s3://qts3fortesting-1
  1. Create a directory with following files
    • 1.txt
    • 2.txt
    • 3.xml
    • 4.json
  2. Copy all the files to s3 bucket except 3.xml
aws s3 cp ".\testing\" s3://qts3fortesting-1 --recursive --exclude 3.xml
  1. Create one more s3 bucket and copy the contents of the above bucket to new bucket
aws s3 mb s3://qts3fortesting-2
 aws s3 cp s3://qts3fortesting-1/ s3://qts3fortesting-2 --recursive
  1. remove the old bucket.
 aws s3 rb s3://qts3fortesting-1/ --force
 aws s3 rb s3://qts3fortesting-2/ --force

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner