AWS CLI

Nityachawda
3 min readMar 6, 2021

--

Description:

we will use cli and perform following tasks:

-> Create a key pair

-> Create a security group

-> Launch an instance using the above created key pair and security group.

-> Create an EBS volume of 1 GB.

-> The final step is to attach the above created EBS volume to the instance you created in the previous steps.

so, lets get started.

To use aws cli first we have to create IAM user.

Now, we will login to aws cli, using command

aws configure

After this command we have to provide login credentials like access key and security key.

After logging in , now we will create key-pairs. For that we have to run the following command:

aws ec2 create-key-pair --key-name <key_name>

Now, we will create a security group by running the following command:

aws ec2 create-security-group --group-name <group_name> --description <description>

Then, we will set the Ingress rules for outside traffic , using command:

aws ec2 authorize-security-group-ingress --group-id <security_group_id> --protocol  <protocol_name>  --port <port_no> --cidr <cidr_value>

Now, we will launch an ec2 instance using key-pair and security-group.

aws ec2 run-instances   --security-group-ids   <group_id>   --instance-type _type_ --image-id <ami_id>   --key-name <key_name>  --count <no_of_instance>

Now we will create EBS volume and then attach it to the ec2 instance created.

command to create EBS volume:

aws ec2 create-volume --volume-type <volume_type> --size <volume_size> --availability-zone <AZ_name>

To attach EBS volume to the ec2 instance use command:

aws ec2  attach-volume   --volume-id <volume_id>   --instance-id <instance_id>  --device <device_name>

THANK YOU

--

--

No responses yet