Skip to content

lucab85/terraform-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Examples

Practical, copy-paste Terraform examples for AWS — each one is a small, self-contained configuration you can init, plan, and apply in minutes. Every example is terraform fmt and terraform validate clean and pinned to current provider versions.

New to Terraform? Start with how to install Terraform on any OS, then come back and run any example below.

Examples

Example What it builds Full walkthrough
aws-ec2-instance A single EC2 instance with a security group, in the default VPC Deploy an EC2 instance with Terraform
aws-s3-bucket A private, versioned, encrypted S3 bucket S3 bucket best practices with Terraform
aws-vpc A VPC with public + private subnets, IGW, and NAT gateway Terraform AWS VPC complete example

Quick start

# 1. Install Terraform (see the install guide linked above)
terraform -version    # 1.5+ recommended

# 2. Pick an example
cd examples/aws-ec2-instance

# 3. Configure AWS credentials (env vars or `aws configure`)
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=us-east-1

# 4. Provision
terraform init
terraform plan
terraform apply

# 5. Tear down when you're done (avoid surprise bills)
terraform destroy

Conventions used in every example

  • Pinned versionsrequired_version and provider version constraints so apply is reproducible.
  • Variables with sane defaults — override via terraform.tfvars or -var.
  • Outputs — every example prints the IDs/IPs you actually need.
  • Tags — resources are tagged so they're easy to find and clean up.
  • No secrets in code — credentials come from the environment or your AWS profile.

Troubleshooting

Hitting an error? The most common Terraform failures (state locks, provider auth, Error creating ... conflicts, dependency cycles) are documented with fixes in the Terraform troubleshooting guide.

Learn more

License

MIT — use these examples freely in your own projects.

About

Practical, copy-paste Terraform examples for AWS (EC2, S3, VPC) — fmt + validate clean, pinned providers.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors