Skip to content

Launching VPC Resources

Category Cloud & AWS Networking
Status โœ… Completed
Repo nextwork-launching-vpc-resources
Original NextWork guide nextwork.ai

Learning project

Practice work following a NextWork guide, separate from my production projects.

๐Ÿ“š NextWork learning project. This is a practice project I built while working through NextWork's Launching VPC Resources guide. It is part of my Learning portfolio and is fully separate from my production projects.

Category: Learning โ€บ Cloud & AWS Networking
Status: โœ… Completed

Overview

Part 4 of the VPC series puts servers into the network: a public EC2 instance and a private one. The private instance's security group only accepts SSH from the public instance's security group. The guide's 'launch your VPC in minutes' step (the VPC wizard) is exactly what this Terraform does in one apply.

Summary

Deployed for real on AWS: public and private EC2 instances (Amazon Linux 2023, t2.micro) in their subnets. 15/15 checks passed, I SSHed into the public server and reached the internet from it, then everything was torn down.

The checks behind this are in docs/verification.txt.

Skills & tools

Amazon VPC, Subnets, CIDR, Terraform, Infrastructure as Code, boto3, moto (AWS mock), Amazon EC2, Security group referencing

What I built

  • main.tf: the full VPC, plus public and private aws_instance resources, a private SG that references the public SG, and an SSH rule.
  • checks.py: confirms instance placement, that the private instance has no public IP, and that SG-to-SG SSH works as intended.

How to run

pip install -r requirements-dev.txt   # moto (local AWS mock) + boto3
./local-test.sh                       # terraform apply against the mock, run checks.py, then destroy

# Real AWS (costs money; use your own IAM user/profile):
terraform init && terraform apply      # mock_endpoint defaults to "" = real AWS
terraform destroy                      # clean up when done

Verification

I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.

PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH TF_PLUGIN_CACHE_DIR=/workspace/nextwork-portfolio/tf-plugin-cache ./local-test.sh

Real AWS deployment (2026-12-02)

I deployed this project to a real, dedicated AWS learning account (us-east-1, kept separate from everything else I run), checked it, captured the output, and tore it all down right after. Every resource carried the tag Project=nextwork-launching-vpc-resources so I could prove nothing was left behind.

How I ran it: ./real-aws-run.sh (in this repo) does terraform init/apply with my AWS profile, runs checks.py against the real account, runs real-extra.sh for the live tests, and then always runs terraform destroy, even if a step fails. To get onto the instances I used EC2 Instance Connect with a throwaway SSH key that is only valid for 60 seconds. No key pairs were created in AWS and no keys were saved.

Evidence (excerpt; the full, sanitized transcript is in docs/aws-real-run.txt, with the account ID redacted):

$ python3 checks.py   (against the real account)
ALL 15 CHECKS PASSED
$ ./real-extra.sh
--- instances (state, subnet, public IP)
-------------------------------------------------------------------------------------------------
|                                       DescribeInstances                                       |
+--------------------------+----------+----------------------------+-------------+--------------+
|  NextWork Public Server  |  running |  subnet-063f2b43f8e2e571e  |  10.0.0.141 |  100.54.36.5 |
|  NextWork Private Server |  running |  subnet-07528eed1a2998180  |  10.0.1.159 |  none        |
+--------------------------+----------+----------------------------+-------------+--------------+
--- ssh into NextWork Public Server
hello from ip-10-0-0-141.ec2.internal / "Amazon Linux 2023.12.20261127"
curl https://example.com -> HTTP 200

Teardown

Resources were up from 19:22 to 19:24 CST on 2026-12-02, then destroyed and verified gone:

=== TEARDOWN 2026-12-02 19:24 CST ===
$ terraform destroy -auto-approve -input=false -no-color -var ami_id=ami-000d209a4fc9822c4 -var project_tag=nextwork-launching-vpc-resources
Destroy complete! Resources: 15 destroyed.
$ terraform state list   (should be empty)
$ aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=nextwork-launching-vpc-resources

Cost

Estimated cost of the real run: about $0.01 (two t2.micro instances and one public IPv4 address for about 2 minutes). The account has a $50/month budget with email alerts at $5, $20 and $40, and the whole AWS series is logged in a private spend ledger.


Original project: https://nextwork.ai/projects/8f49d756-9e51-58c0-856a-e71e54f064ab ยท Part of my NextWork Learning portfolio (hub).

Verification output

From docs/verification.txt:

$ PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH TF_PLUGIN_CACHE_DIR=/workspace/nextwork-portfolio/tf-plugin-cache ./local-test.sh

Success! The configuration is valid.

Apply complete! Resources: 15 added, 0 changed, 0 destroyed.
igw_id = "igw-428812cf723d98ee5"
private_instance_id = "i-a93e61a6d941a979c"
private_sg_id = "sg-cfee473509edd8dda"
private_subnet_id = "subnet-2cb05271fa3c7d855"
public_instance_id = "i-3633ea1b1303c1696"
public_instance_public_ip = "54.214.42.230"
public_subnet_id = "subnet-3e3ac3ab1ebaba0a0"
vpc_id = "vpc-9636c7e93f1e0dd80"
web_sg_id = "sg-93e76c07649cfb531"
PASS: VPC CIDR is 10.0.0.0/16
PASS: public subnet 10.0.0.0/24 in VPC
PASS: public subnet auto-assigns public IPs
PASS: IGW attached to VPC
PASS: public subnet has its own route table
PASS: default route 0.0.0.0/0 -> IGW
PASS: SG allows HTTP 80 from anywhere
PASS: custom NACL associated with public subnet
PASS: private subnet 10.0.1.0/24 does not auto-assign public IPs
PASS: private route table has NO internet route
PASS: private NACL only admits the public subnet
PASS: public instance in public subnet
PASS: private instance in private subnet
PASS: private instance has no public IP
PASS: private SG allows SSH only from the public SG
ALL 15 CHECKS PASSED

[exit code 0]