CLI AWS Notes
CLI AWS Notes
AWS CLI
==========
===========================
Using the AWS web console:
===========================
============================
AWS Command Line Interface:
============================
Usually, the script provides you with the flexibility to manage multiple AWS
resources, infrastructures effectively.
For example, we can use the script to deploy multiple resources without the need to
go through a complete configuration wizard each time.
============================
Configuring AWS CLI
=============================
2) Create IAM user with Security Credentials and note down Access Keys
3) Install AWS CLI: AWS CLI is available for Windows, MAC and Linux distribution of
OS.
b) MAC and Linux: Please follow these steps (execute below commands)
Note: AWS configure command will ask for access key, secret access key, region and
output format.
Step-2: Next, we are going to run “aws s3 ls" (to display bucket lis)
$ aws s3 ls
Step-3: After listing out the content of the existing bucket, let us try to create
a new s3 bucket using AWS CLI
$ aws s3 mb s3://ashokitbucket1
Step-5: After the command has been executed, let us check, if the bucket has been
created and what is the region of the bucket.
$ aws s3 rb s3://ashokitbucket1
===========================
List out all ec2 instances
===========================
$ aws ec2 describe-instances
or a tag key:
=========================================
Create a New Key Pair for EC2 Instances
=========================================
-> Before launching a new EC2 instance we’ll need an SSH key pair that we’ll use to
connect to it securely.
The above command will create a new key in the AWS named ashokitkey and pipe the
secret key directly to the location we specify, in this case, ashokitkey.pem.
========================
Launch New EC2 Instances
========================
$ aws ec2 run-instances --image-id ami-0607784b46cbe5816 --instance-type t2.micro
--key-name ashokitkey
=================================
Stop and Start an EC2 Instance
=================================
========================
Terminate an Instance
========================
$ aws ec2 terminate-instances --instance-ids <instance-id>
================================
Creating Security Group in EC2
================================
$ aws ec2 create-security-group --group-name MySecurityGroup --description "My
security group"
=============================
Creating RDS instance (MySQL)
=============================
========================
Delete RDS Instance (MySQL)
========================
$ aws rds delete-db-instance ^
--db-instance-identifier test-mysql-instance ^
--skip-final-snapshot ^
--no-delete-automated-backups