Skip to content

Build a Virtual Private Cloud

Category Cloud & AWS Networking
Status โœ… Completed
Repo nextwork-build-a-virtual-private-cloud
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 Build a Virtual Private Cloud 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 1 of the Amazon VPC series. In the console, the guide creates a VPC (10.0.0.0/16), a public subnet (10.0.0.0/24) with auto-assigned public IPs, and an internet gateway attached to the VPC. I reproduced those steps as Infrastructure as Code.

Summary

Deployed for real on AWS: VPC 10.0.0.0/16, a public subnet with auto-assigned public IPs, and an attached internet gateway. All checks passed against the live account, 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)

What I built

  • main.tf: VPC, public subnet, internet gateway.
  • providers.tf: AWS provider that can target real AWS or a local moto endpoint.
  • checks.py: boto3 assertions (CIDRs, auto-assigned public IP, IGW attachment).
  • local-test.sh: one-command offline apply โ†’ check โ†’ destroy.

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

Notes

  • Secret mission topics: VPC vs. subnet vs. AZ, and why /16 and /24.
  • A subnet only becomes truly public once a route table sends 0.0.0.0/0 to the IGW. That's Part 2.

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-build-a-virtual-private-cloud 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.

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 4 CHECKS PASSED

Teardown

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

=== TEARDOWN 2026-12-02 19:18 CST ===
$ terraform destroy -auto-approve -input=false -no-color -var project_tag=nextwork-build-a-virtual-private-cloud
Destroy complete! Resources: 3 destroyed.
$ terraform state list   (should be empty)
$ aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=nextwork-build-a-virtual-private-cloud

Cost

Estimated cost of the real run: $0.00 (VPCs, subnets and internet gateways are free). 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/7f907ac7-2473-5c15-a8be-edb36581cdba ยท 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: 3 added, 0 changed, 0 destroyed.
igw_id = "igw-01b91f2a1c27f6620"
public_subnet_id = "subnet-70456dc811b3eff3c"
vpc_id = "vpc-cd56e8244510292d8"
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
ALL 4 CHECKS PASSED

[exit code 0]