Getting started with AWS CLI
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
To use AWS CLI, firstly install AWS CLI version 2 (latest version). For download the AWS CLI MSI installer for Windows (64-bit):
https://awscli.amazonaws.com/AWSCLIV2.msi
After installing, to confirm that installing is done properly use following command:
If it installed properly it shows the above output.
After install we have to configure it for configure run the aws configure command-:
To give the access id and secret access key we first create a IAM user from AWS WebUI. After creating IAM there we get access key and secret key-:
Fill the values of Access key and secret key in above fields along with region. By default output format is JSON but you can change it too (in this case i am not changing it). After fill above on again run the aws configure we get following output-:
If all the above steps performed successfully it means now you are able to use AWS services using CLI. To get information of the instances that currently running or stopped in your account like a Linux instance is currently stopped in my console-:
Now, Let’s do some small tasks using CLI-:
- Creating a Key Pair-:
To create a key pair and store it is form of text we use the following command-:
aws ec2 create-key-pair --key-name {name} --query 'KeyMaterial' --output text > {name}.pem
2. Create a Security Group -:
To create security group for getting groupID we use following command-:
aws ec2 create-security-group --group-name {name}--description "{name}"
3. To get subnet id we have two options either use a default or to create a new id using network interface of aws.
4. Launch a Instance using above created key pair and security group and subnet Id. For this we use following command-:
aws ec2 run-instances --image-id {ami-id} --count {number} --instance-type {type} --key-name {Key_Pair_Name} --security-group-ids {group-id} --subnet-id {subnet-id}
Now, check the aws console WEBUI-:
5. Create an EBS volume of 1 GB. For this we use the command-:
aws ec2 create-volume --volume-type {type} --size {size} -availability-zone {zone-name}
6. Attach this volume to instance that launched above-:
aws ec2 attach-volume --volume-id {vol-id} --instance-id {i-id} --device /dev/{name}
Finally, We check the instance using the command-:
aws ec2 describe-instances
7. To stop instance we use the command-:
aws ec2 stop-instances --instance-ids {id}
For further information refer the AWS instances https://docs.aws.amazon.com/
I have just started my AWS journey and will share more knowledge as I learn more. I am open for your suggestions to improve this article and increase my knowledge.
Thank You 😊😊
#awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #arthbylw #awsbylw