Launch an AWS EC2 Instance in a Virtual Private Cloud (VPC) for Cloud and DevOps Engineers

Launch an AWS EC2 Instance in a Virtual Private Cloud (VPC) for Cloud and DevOps Engineers

Learning path for the AWS Cloud Practitioner exam

📝Introduction

In this blog post, we will cover a simple and intro hands-on lab, creating a virtual private cloud (VPC), subnets across multiple Availability Zones (AZs), routes and an internet gateway, and more. These services are the foundation of networking architecture inside of AWS and cover concepts such as infrastructure, design, routing, and security.

📝Log in to the AWS environment

Using your credentials, make sure you're using the right Region. In my case, I chose us-east-1.

📝Create a VPC

Navigate to VPC > Your VPCs.

Click Create VPC, and set the following values:

Select: VPC Only

Name tag: <name_vpc>

IPv4 CIDR block: xx.xx.xx.xx/x (I chose to use 10.0.0.0/16)

Leave the IPv6 CIDR block and Tenancy fields as their default values.

Click Create VPC.

📝Create a Public Subnet

Click Subnets in the left-hand menu.

Click Create subnet, and set the following values:

VPC ID: <name_vpc>

Subnet name: <name_subnet>

Availability Zone: xxxx (I chose to use us-east-1a)

IPv4 CIDR block: xx.xx.xx.xx/x (I chose to use 10.0.0.0/24)

Click Create subnet.

📝Create Routes and Configure Internet Gateway

Click Create internet gateway.

On the next screen, click Actions > Attach to VPC.

In the Available VPCs dropdown, select <name_vpc>.

Click Attach Internet gateway. Click Route Tables in the left-hand menu.

Click Create route table, and set the following values:

Name: publicRT

VPC: <name_vpc>

Click Create route table. On the next screen, click Edit routes.

Click Add route, and set the following values:

Destination: 0.0.0.0/0

Target: Internet Gateway, <name_internet_gateway>

Click Save changes. Click the Subnet associations tab.

Click Edit subnet associations. Select the box for <name_subnet>.

Click Save associations.

📝Launch EC2 Instance in Subnet

Navigate to EC2 > Instances.

Click Launch instances.

On the AMI page, select the Amazon Linux 2 AMI. Ensure t2.micro is selected and leave the other options as default.

Click Review and Launch > Launch.

In the key pair dialog, select Create a new key pair.

Give it a Key pair name of <name-keypair>.

Click Download Key Pair.

Click Launch Instances. Click View Instances, and give it a few minutes to enter the Running state.

📝Access EC2 Instance

Once the instance has a Running state, select the box next to it.

Click Connect at the top.

In the EC2 Instance Connect section, click Connect.

This will open a new browser tab showing a command line interface.

Congratulations — you've completed this hands-on lab covering the basics to Launch an AWS EC2 Instance in a Virtual Private Cloud (VPC).

Thank you for reading. I hope you were able to understand and learn something helpful from my blog.

Please follow me on Hashnode and on LinkedIn franciscojblsouza