Accessing of AWS through CLI
HELLO FRIENDS !!
FIRST OF ALL WE CAN ACCESS AWS THROUGH DIFFERENT MODE EITHER FROM WEB UI OR CLI
HERE I AM GOING TO TELL YOU HOW WE CAN ACCESS DIFFERENT SERVICES VIA COMMAND LINE INTERFACE (CLI)
1. Create a key pair
2. Create a SECURITY GROUP
3. Launch an EC2 instance using key pair & security group
4. Create an EBS Volume
5. Attach EBS Volume to the EC2 instance
6. Detach the EBS Volume
What is 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.
The AWS CLI v2 offers several new feature including improved installers, new configuration options such as AWS Single Sign-On (SSO), and various interactive features.
Prerequisite: Download AWS CLI version 2 for Windows (64-bit):
- For the latest version of the AWS CLI: https://awscli.amazonaws.com/AWSCLIV2.msi
In CLI we have to give access key and secret key (password).For this we have to connect to AWS cloud
We can get our access key and password through a service of AWS called IAM.
What is IAM?
AWS Identity and Access Management (IAM) is a web service that helps you securely control access to AWS resources. You use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources.
When you first create an AWS account, you begin with a single sign-in identity that has complete access to all AWS services and resources in the account. This identity is called the AWS account root user and is accessed by signing in with the email address and password that you used to create the account. We strongly recommend that you do not use the root user for your everyday tasks, even the administrative ones.
LETS BEGIN -
- WE HAVE TO CREATE IAM USER
IAM USER SUCCESSFULLY CREATED
Created one Access key ID and Secret access key!!
Now copy and paste the Access key ID and Secret access key in command line
AWS is a Umbrella of services !
1. CREATE ONE KEY PAIR USING CLI
What is KEY PAIR?
A key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance. Amazon EC2 stores the public key, and you store the private key. You use the private key, instead of a password, to securely access your instances. Anyone who possesses your private keys can connect to your instances, so it’s important that you store your private keys in a secure place.
2. Now create one security group for our instance
What is SECURITY GROUP?
A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. When you launch an instance in a VPC, you can assign up to five security groups to the instance. Security groups act at the instance level, not the subnet level. Therefore, each instance in a subnet in your VPC can be assigned to a different set of security groups.
3. Now we are going to launch an EC2 Instance using the keypair and security group
What is EC2 Instance?
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.
WE CAN TAKE THE HELP OF HELP COMMAND
> aws ec2 run-instances --image-id <image id>--count 1 --instance-type t2.micro --key-name <key pair name> --security-group-ids <security group id> --subnet-id <subnet id>
Now to run instance use the below command:
We can check it :
To get the information about the instance we can use describe command
TO STOP THE INSTANCE :
TO TERMINATE THE INSTANCE:
WE CAN CHECK:
4. Now we are going to Create an EBS Volume of 1 GB using CLI :
What is EBS VOLUME?
Amazon Elastic Block Store (EBS) is an easy to use, high performance block storage service designed for use with Amazon Elastic Compute Cloud (EC2) for both throughput and transaction intensive workloads at any scale. A broad range of workloads, such as relational and non-relational databases, enterprise applications, containerized applications, big data analytics engines, file systems, and media workflows are widely deployed on Amazon EBS.
5. Now attach the EBS Volume to EC2 instance
We can check :
EBS instance attached to EC2 instance
6. Now to detach the volume (Hard disk)
THANK YOU ALL FOR READING!