AWS Command Line Interface Part 1
AWS Command Line Interface Part 1
Configure AWS CLI with IAM user Credentials with specific Region
# aws configure
To Delete a Volume
# aws ec2 delete-volume --volume-id <volume Id>
Output: None
To create a snapshot
This example command creates a snapshot of the volume with a volume ID
of <volume Id> and a short description to identify the snapshot.
# aws ec2 create-snapshot --volume-id <volume Id> --description "<Description>"
Create-load-balancer
Create-db-Instance
Create a bucket
Use the s3 mb command to make a bucket. Bucket names must be globally unique
(unique across all of Amazon S3) and should be DNS compliant.
Bucket names can contain lowercase letters, numbers, hyphens, and periods.
Bucket names can start and end only with a letter or number, and cannot contain a
period next to a hyphen or another period.
Move objects
Delete Objects
Empty Bucket
Delete Bucket
Create a VPC with a 10.0.0.0/16 CIDR block using the following create-vpc
command.
# aws ec2 create-vpc --cidr-block <Ip address> --query Vpc.VpcId --output text
Using the VPC ID from the previous step, create a subnet with
a 10.0.1.0/24 CIDR block using the following create-subnet command.
# aws ec2 create-subnet --vpc-id <vpc - Id>--cidr-block <Ip address>
Using the ID from the previous step, attach the internet gateway to your VPC
using the following attach-internet-gateway command.
# aws ec2 attach-internet-gateway --vpc-id <vpc - Id>--internet-gateway-id <Igw - Id>
Create a custom route table for your VPC using the following create-route-table
command.
# aws ec2 create-route-table --vpc-id <vpc - Id>--query RouteTable.RouteTableId --
output text
Create a route in the route table that points all traffic (0.0.0.0/0) to the internet
gateway using the following create-route command.
# aws ec2 create-route --route-table-id <route table - Id>--destination-cidr-block
0.0.0.0/0 --gateway-id <Igw - Id>
You can describe the route table using the following describe-route-tables
command.
# aws ec2 describe-route-tables --route-table-id <route table - Id>
The route table is currently not associated with any subnet. You need to
associate it with a subnet in your VPC so that traffic from that subnet is routed to
the internet gateway.
# aws ec2 describe-subnets --filters "Name=vpc-id,Values=<vpc –Id>
" --query "Subnets[*].{ID:SubnetId,CIDR:CidrBlock}"
You can choose which subnet to associate with the custom route table, for
example, subnet-0c312202b3f26703a, and associate it using the associate-route-
table command. This subnet is your public subnet.
# aws ec2 associate-route-table --subnet-id <subnet-Id> --route-table-id <route table
- Id>
CLEAN UP
Creating Alarm
# aws cloudwatch put-metric-alarm --alarm-name <Alarm name> --alarm-description
"<Description>" --metric-name <Metric> --namespace AWS/EC2 --statistic Average -
-period 300 --threshold <70> --comparison-operator <GreaterThanThreshold> --
dimensions "Name=InstanceId,Value=<Id>" --evaluation-periods 2 --alarm-actions
<SNS – arn > --unit Percent