Overview
Lab details
- This Lab walks you through the steps to create an EC2 instance and run a few AWS CLI Commands.
- Duration: 45 minutes
- AWS Region: US East (N. Virginia) us-east-1.
Architecture diagram

Task Details
- Sign into the AWS Management Console.
- Launch an EC2 instance.
- SSH into the EC2 Instance.
- AWS CLI Command to create a KeyPair.
- AWS CLI Command to create a Security group.
- AWS CLI Command to create an EC2 Instance.
- View the EC2 instance.
- Validation of the lab
- AWS CLI Command to terminate the EC2 instance.
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
-
On the AWS sign-in page,
- Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. Otherwise, you cannot proceed with the lab.
- Now copy your Username and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign-in button.
- Once Signed In to the AWS Management Console, make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2: Launching an EC2 Instance
- Make sure you are in the N.Virginia Region.
- Navigate to Services menu in the top, then click on EC2 in the Compute section.
- Click on Instances from the left sidebar and then click on Launch Instances
- Name : Enter MyEC2Instance
- For Amazon Machine Image (AMI): Search for Amazon Linux 2023 AMI in the Quick Start menu.

-
For Instance Type: select t2.micro

-
For Key pair: Select Create a new key pair Button
- Key pair name: MyEC2-key
- Key pair type: RSA
- Private key file format: .pem
- Select Create key pair Button.
-
In Network Settings Click on Edit:
- Auto-assign public IP: Enable
- Select Create new Security group
- Security group name : Enter MyEC2-SG
- Description : Enter Security Group to allow traffic to EC2
-
To add SSH,
- Choose Type: SSH
- Source: Anywhere (From ALL IP addresses).
-
Expand Advanced details :
- In IAM instance profile Select EC2LimitedLaunchRole
- Keep rest thing Default and Click on Launch Instance Button.
- Select View all Instances to View the Instance you Created
-
Launch Status: Your instance is now launching. Click on the instance ID and wait until the initialization status changes to running.

Task 3: SSH into the EC2 Instance
- Please follow the steps in SSH into EC2 Instance.
Task 4: AWS CLI command to create a Key Pair
- This command will create a Key Pair in the us-east-1 region.
-
Run this command, to set necessary permissions.
Task 5: AWS CLI command to create a Security Group
- The below command will create a Security Group in the us-east-1 region.
-
Once you get the below output, you have successfully created a Security Group.

Task 6: AWS CLI command to create an EC2 Instance
- The below command will create one t2.micro EC2 instance with Amazon Linux 2 AMI in the us-east-1 region.

Task 7: View the EC2 instance you created
- Make sure you are in the N.Virginia Region.
- Navigate to Services menu in the top, then click on EC2 in the Compute section.
- Navigate to Instances in the left panel.
-
You will be able to see the new EC2 instance has been created. Copy the instance ID for later use.

Task 8 : Validation Test
- Once the lab steps are completed, please click on the Check my work button on the left side panel.
- This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
- Sample output :

Task 9: AWS CLI command to Delete the EC2 instance
The below command will terminate the EC2 instance which was previously created.-
Once you see the below output, your EC2 instance has started to terminate.

-
Now navigate to your EC2 dashboard, and you will be able to see that the EC2 instance state changed to terminated.

Completion and conclusion
- You have successfully created and launched an Amazon EC2 Instance.
- You have successfully logged into an EC2 instance by SSH.
- You have successfully created a key pair via AWS CLI command.
- You have successfully created a Security group via AWS CLI command.
- You have successfully created an EC2 Instance via AWS CLI command.
- You have successfully terminated the EC2 Instance via AWS CLI command.
End lab
- Sign out of AWS Account.
- You have successfully completed the lab.
- Once you have completed the steps, click on End lab in the IP Lab Portal.
What gets checked
When you press Check my work, the platform verifies each of these:- Launch an EC2 Instance — Check whether an EC2 Instance is launched or not.
- Launch EC2 AMI type Amazon Linux — Check whether the EC2 instance is launched using an Amazon AMI.