CLI

How to use CLI
- First step is to setup access in IAM by creating a user with programmatic access.
- To use the AWS CLI you type AWS and then the service that you want to access:
Configure your credentials:
aws configure
You will be prompted to supply your AWS Access Key ID, AWS Secret Access Key & Default Region Name.
                                    
CLI Commands
List all your S3 buckets:
aws s3 ls
Create a new S3 bucket:
aws s3 mb s3://testbucket12345678
If you navigate to your home directory in your EC2 instance by typing cd ~ and then cd .aws, you will find your config and credentials files containing your actual secret and access key.
AWS always suggest not to store your credentials in any file or public accessable location, rather use IAM Roles.
                                    
Using Roles instead of credentials files
cd ~
rm -rf .aws
- Sign into the AWS Console and navigate to your EC2 instance.
- Click on Actions > Instance Settings > Attach/Replace IAM Role.
- Select Role and then you will now be able to use the CLI in your EC2 instance with all the permissions assigned to the role.