All hands-on labs

Premium Hands-on labbeginnerAWS

Deploying EC2 instances in a custom VPC with Terraform

This lab environment provides you with the ability to practice using Terraform to deploy EC2 instances in a custom VPC with public and private subnets, NAT Gateways, and Internet Gateway, Security Groups, and SSM.

  • 9 guided tasks
  • Terminal in the browser

Scenario

This lab is part of the Terraform on AWS course. It continues the course project, which you build across the lessons from Our project details to Creating our EC2 instance module. If you completed those lessons in your own terminal, open your project directory, skip the next task, and go to "Configure your AWS CLI".

You can also see the course project code on GitHub. The repository holds the finished project, so it also includes the modules from later lessons.

In this lab, you'll add two EC2 instances to the course project's custom VPC: one in a public subnet and one in a private subnet. You'll deploy the whole project with Terraform, read the instance IDs it outputs, and then destroy everything you built.

What you will learn

  • Prepare the course project code for the VPC, SSM, and EC2 modules.
  • Call the EC2 module twice to place one instance in a public subnet and one in a private subnet.
  • Output the instance IDs from the root module.
  • Deploy the project with terraform init, plan, and apply, then remove it with terraform destroy.
Hands-on lab

Deploying EC2 instances in a custom VPC with Terraform

Included in Cybr Premium.