Terraform + HCP Terraform
Intro:
A minimal AWS VPC with 1 public and 1 private subnet, managed with Terraform and deployed via HCP Terraform (free tier).
## Prerequisites
| Tool | Version | Purpose |
| — — — | — — — — -| — — — — -|
| Terraform | >= 1.5.0 | Local testing (optional) |
| HCP Terraform (free) | — | Remote execution |
| AWS Account | — | Target infrastructure |
| AWS Access Key | — | Credentials for HCP Terraform |
| Git | — | Version control |
Step 1— Create an HCP Terraform Account
- Go to app.terraform.io
- Sign up (free Hobby tier is enough)
- create an organization: follow the prompts, choose personal, give it a name and create.
- create a workspace, give it a name and create.
Step 2— Create a github account or log in if it already exist.
- clone the repo (optional): https://github.com/Louis-K-star/terraform-cloud-testing.git. Customize as you wish and push to your repo. Beforehand create a new branch to work on.
- You can choose or write a different code to push in the repo to test if you like.
Step 3— Connect HCP Terraform to Your GitHub Repo
- open your workspace, choose Version control workflow type
- connect to gitlab vcs, choose the branch, give a name and follow the prompts to connect.
Step 4— Add AWS Credentials
- In your workspace, go to Variables
- Add the created aws credentials that terraform cloud will use to authenticate:
| Key | Value | Category | Sensitive |
| — — -| — — — -| — — — — — | — — — — — -|
| `AWS_ACCESS_KEY_ID` | `AKIA…` | Environment variable | ✅ |
| `AWS_SECRET_ACCESS_KEY` | `wJal…` | Environment variable | ✅ |
Get K. Louis’s stories in your inbox
Join Medium for free to get updates from this writer.
3. Click Save
Step 6— Run a Plan
- Go to your workspace main page
- Click “new run” or “runs”
- Review the output — you should see 7 resources to create:
- 1 VPC
- 1 Internet Gateway
- 2 Subnets
- 2 Route Tables
- 2 Route Table Associations
Step 7— Apply
- After the plan succeeds, click “Apply”
- Wait for it to complete
- Check Outputs in the workspace to see
vpc_id,public_subnet_id,private_subnet_id
Step 8— Verify in AWS Console
- Go to AWS Console → VPC → Your VPCs
- You should see the
vpcwith:
- 1 Internet Gateway
- 2 Subnets (one public, one private)
- 2 Route Tables
Step 9— Destroy (Cleanup)
- Go to Workspace → Settings → Destruction and Deletion
- Toggle on “Allow destroy plans” if not already enabled
- click “Destroy”
- Review the destroy plan
- Click “Confirm Destroy”
- All resources are deleted
Conclusion
In this lab, we built a minimal but complete AWS VPC — one public subnet, one private subnet, an Internet Gateway, and the route tables that wire them together — and deployed it entirely through HCP Terraform without ever touching a terminal.
Here’s what you should take away:
Infrastructure as Code isn’t magic. It’s just text files that describe what you want. Terraform reads them, plans the changes, and applies them. You never click around a console.
HCP Terraform removes the “it works on my machine” problem. State lives in the cloud. Your team can see what’s running, who changed it, and when. Destroy is one button. No more terraform.tfstate files lost in a forgotten folder.
The free tier is enough to learn. You don’t need an enterprise plan to understand the workflow. Plan → Apply → Destroy. Variables. Outputs. That’s the loop you’ll repeat in every real project.





