> For the complete documentation index, see [llms.txt](https://gyansetu-aws.gitbook.io/aws-cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-aws.gitbook.io/aws-cloud/practical-7.md).

# Practical

1. **Attaching s3 role to ec2**

* &#x20;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&#x20;
* 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 nam&#x65;**>**

**6.Copying from bucket**

* aws s3 s3://\<bucket name>/\<F.N>.

#### &#x20; **7.**&#x53;yncing Bucket with local disk

* aws s3 sync s3://\<bucket name>.storage
* Cmd to sync all data from bucket to local

&#x20;**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&#x20;

1. Install the python&#x20;
2. &#x20;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. &#x20; Check pip is installed or not (#pip list)
4. &#x20; Use pip to install awscli (#pip install awscli botocore, botocore is the package awscli uses for all its work)
5. &#x20;. Use aws cmd (#aws s3 ls

&#x20;**AWSCLI in WINDOWS**&#x20;

* &#x20;Launch an windows instance
* &#x20;Login&#x20;
* .Install awscli msi installer from aws website (google for awscli for windows)
* &#x20;4\. Open the cmd prompt and start executing aws cmd.
