How to use the Terraform Code Generator
- 1. Name the projectUsed for resource names and tags, and choose the region.
- 2. Pick resourcesVPC with public subnets, an EC2 web server with open ports, an S3 bucket, and optional remote state.
- 3. GenerateDownload versions.tf, variables.tf, main.tf and outputs.tf as a ZIP.
What you get
The generator writes a small, conventional Terraform project for the AWS provider (version 6). The VPC gets public subnets spread across availability zones, an internet gateway and a route table. The EC2 server uses the latest Ubuntu 24.04 image from Canonical's official account (Arm or x86 to match the instance type), an encrypted gp3 disk, IMDSv2-only metadata and a security group with only the ports you list; SSH is limited to the network you give. The S3 bucket blocks all public access and encrypts data, with optional versioning. Default tags mark everything with the project name. Nothing is uploaded; the files are built in your browser.
We generated every combination of options and parsed each file with python-hcl2, checking that every variable, resource and data source referred to is defined. We couldn't run terraform validate or create real resources in our test environment.
Worked example
The defaults (project uncodemy-demo in Mumbai, a VPC with 2 public subnets, a t3.micro web server with ports 22, 80 and 443 and SSH only from 203.0.113.0/24, and a versioned S3 bucket) produce 11 resources across 4 files, with outputs for the VPC ID, subnet IDs, the server's public IP and the bucket name.
Before you apply
- Run
terraform planand read every line beforeapply. - Resources cost money while they exist; run
terraform destroyafter practising. - With remote state, create the state bucket first; S3 native locking (
use_lockfile) needs Terraform 1.10 or later.
Frequently asked questions
Does it work with OpenTofu?
Yes, this HCL works with OpenTofu as well as Terraform.
Where do my AWS keys go?
Nowhere in these files. Terraform reads credentials from the AWS CLI configuration or environment variables.
Is the Terraform generator free?
Yes. You can open the Terraform generator and change every input and rate without signing up. When you generate the files for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.