AWS Command Line Interface -Basic Tutorial
Hey Everyone…
In this tutorial we will learn to :
- Install AWS Command Line Interface v2
- Create an EC2 Key Pair
- Create a Security Group
- Create a new EC2 instance
- Create a new volume of 1GB storage
- Attach the volume to the created instance
AWS CLI Installation :
- Linux : In the terminal use commands
# curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o “awscliv2.zip”
# unzip awscliv2.zip
# sudo ./aws/install
- Windows : Download and install from the below link
https://awscli.amazonaws.com/AWSCLIV2.msi
- Use below command to check whether AWS CLI is installed
# aws ‐‐version
- Create a new user with Access ID and Secret Key using IAM Service from the AWS Console
- Use the below command to connect to your AWS account
# aws configure
Key Pair Creation :
- Use the below command to check all the available services of AWS
# aws help
- Upon searching on the services you will find EC2 service
- Use below command to check the operations which can be done on the EC2 service
# aws ec2 help
- Upon searching we will find a command “create-key-pair” which is used to create key pairs
- Use the below command to create a key pair
# aws ec2 create-key-pair ‐‐key-name <key_name>
- You can verify the key pair generation from the AWS Console
Security Group Creation :
- Use the below command to create a new security group
# aws ec2 create-security-group ‐‐group-name <group_name> ‐‐description “<description>”
Instance Creation :
- Use the below command to create a new instance
# aws ec2 run-instances ‐‐image-id <ami-id> ‐‐instance-type <instance_type> ‐‐count <value> ‐‐subnet-id <subnet-id> ‐‐security-group-id <sg-id> ‐‐key-name <key_name>
- We can verify whether the instance is created using the command and also from the AWS Console
# aws ec2 describe-instances
Volume Creation :
# aws ec2 create-volume ‐‐volume-type <volume_type> ‐‐size <value> ‐‐availability-zone <zone_id>
Attach Volume :
# aws ec2 attach-volume ‐‐instance-id <instance_id> ‐‐volume-id <volume_id> ‐‐device /dev/sdp
End of tutorial!!!
You have successfully used AWS CLI to use Amazon Web Services