0% found this document useful (0 votes)
4 views

Creating Linux Instance Using CLI

This document provides a step-by-step guide for creating a Linux instance using the AWS CLI. It includes instructions for installing and configuring the AWS CLI, creating an IAM user with necessary permissions, launching an EC2 instance, creating a security group, and managing the instance lifecycle. Key commands for each step are also provided for user reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Creating Linux Instance Using CLI

This document provides a step-by-step guide for creating a Linux instance using the AWS CLI. It includes instructions for installing and configuring the AWS CLI, creating an IAM user with necessary permissions, launching an EC2 instance, creating a security group, and managing the instance lifecycle. Key commands for each step are also provided for user reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Creating Linux Instance Using CLI

Step1: Install AWS CLI.

Make sure you have the AWS CLI installed. Download Link

Step2: Configure AWS CLI

To configure AWS using the AWS CLI, IAM user credentials are required. These credentials,
including an access key ID and secret access key, must belong to an IAM user.

I. Create IAM user

i. Log in to the AWS Management Console.

www.pitcsolutions.com
ii. Navigate to IAM Dashboard.

www.pitcsolutions.com
iii. Navigate to User groups and click Create group.

iv. Now provide User group name and attach permission policies as required and Click
create group at the bottom right corner.

Attach permissions: “AdministratorAccess” , “AmazonEC2FullAccess”

www.pitcsolutions.com
v. Navigate to Users and click Create user.

vi. Provide user name and click next

www.pitcsolutions.com
Now, Select Permission options, then select user groups and click Next.

Now, in Review and create step Click create user.

www.pitcsolutions.com
vii. Now, navigate to ‘Users’ and then click on the User name i.e. ‘user1’

viii. Now Click Security Credentials.

www.pitcsolutions.com
Scroll down and to Access keys and click Create access key.

Then, Select Command Line Interface (CLI).

And Click Next.

www.pitcsolutions.com
Now, Click ‘Create access key’.

Then, Download the .csv file and click Done.

The .csv file contains “Access key ID, Secret access key”.

www.pitcsolutions.com
ix. Now to Configure AWS CLI, open ‘cmd’ prompt.

Write “aws configure ” command and press Enter key.

Now provide Access Key Id, Secret Key Access which are present in the
downloaded .csv file.

www.pitcsolutions.com
Step3: Creating EC2 instance.

Write command : “aws ec2 run-instances --image-id ami-0611295b922472c22 --instance-


type t3.micro”

Now the Instance is created. To check, open EC2 Dashboard.

www.pitcsolutions.com
Then, Click Instances.

Here, we can see that an instance is running.

1. Create Security Group Using CLI with HTTP Protocol

www.pitcsolutions.com
Open cmd prompt.

 To create security group

we can use, “create-security-group” command.


“aws ec2 create-security-group --group-name SecurityGroupName --description "created
using awscli" “

We get Security Group Id: “sg-0ca3c086ad0b9c821”

 To authorize inbound traffic on port 80 (HTTP) in the security group

www.pitcsolutions.com
We can use the “authorize-security-group-ingress” command.
“aws ec2 authorize-security-group-ingress --group-id your_group_id --protocol tcp --port
80 --cidr 0.0.0.0/0”

2. Attach the above Security Group with EC2 instance.

We can use “modify-instance-attribute” command.


“aws ec2 modify-instance-attribute --instance-id your_instance_id --groups
your_group_id”

www.pitcsolutions.com
3. To Stop & Terminate Instance Using CLI

We can use “terminate-instances” command.


“aws ec2 terminate-instances --instance-ids your-instance-id”

Now the instance gets terminated

www.pitcsolutions.com
www.pitcsolutions.com

You might also like