~/terraform-snippet-generator
$

Terraform Snippet Generator

Generate production-ready Terraform/HCL code for AWS, GCP, and Azure — pick a provider, choose a resource, configure options, and export ready-to-use .tf files.

Cloud Provider

Presets

Resource Type

EC2 Instance Configuration

aws_instance

Instance Name

AMI ID

Instance Type

Key Pair Name

Subnet ID (optional)

Security Group IDs (comma-separated)

Tags (key=value, comma-separated)

User Data (shell script)

Generated Terraform Code

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
 
provider "aws" {
region = var.aws_region
}
 
# ---------------------------------------------------------------------------
# Variables
# ---------------------------------------------------------------------------
 
variable "aws_region" {
description = "AWS region"
type = string
default = "us-east-1"
}
 
# ---------------------------------------------------------------------------
# Resources
# ---------------------------------------------------------------------------
 
resource "aws_instance" "main" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "main"
}
}
 
output "main_public_ip" {
description = "Public IP of the EC2 instance"
value = aws_instance.main.public_ip
}
 
output "main_instance_id" {
description = "Instance ID"
value = aws_instance.main.id
}