Practical

  1. Attaching s3 role to ec2

  • Create a role so that from ec2 it is possible toaccess s3 -> Launch and aws ami (no other amican access s3 by default) -> select the rolewhile creating -> launch the instance

2.Help

  • aws

  • aws s3 help

3.Accessing s3 from ec2

  • aws s3 lsCmd to list all buckets in s3

4.Creating bucket

  • aws s3 mb s3://<bucket name>region

  • Cmd to create bucket without specifying

  • aws s3api create-bucket --bucket <bucket name> -region us-east-1 (cannot create in all region becauseof endpoint)

5.Copying to bucket

  • Bucket must a permission so that we can write thechanges to bucket

  • aws s3 cp <F.N> s3://<bucket name>

6.Copying from bucket

  • aws s3 s3://<bucket name>/<F.N>.

7.Syncing Bucket with local disk

  • aws s3 sync s3://<bucket name>.storage

  • Cmd to sync all data from bucket to local

8.Deleting a bucket

  • aws s3 rb s3://<bucket name>

  • aws s3 rb s3://<bucket name> --force

  • Cmd to remove a non-empty bucket

  • aws s3api delete-bucket --bucket <bucket name>

(note: Mumbai region buckets are not supported in awscli)

AWSCLI in RHEL

  1. Install the python

  2. Install pip (By default the package does not comes with repository, download and install python-pip from rpmfind.net, #yum localinstall python-pip) (pip is a package management system used to install and manage software packages written in Python)

  3. Check pip is installed or not (#pip list)

  4. Use pip to install awscli (#pip install awscli botocore, botocore is the package awscli uses for all its work)

  5. . Use aws cmd (#aws s3 ls

AWSCLI in WINDOWS

  • Launch an windows instance

  • Login

  • .Install awscli msi installer from aws website (google for awscli for windows)

  • 4. Open the cmd prompt and start executing aws cmd.

Last updated