Skip to content

Satishchoudhary94/aws-infra-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws — VPC, Security Group, and EC2 (Terraform)

Small, modular Terraform project that creates a VPC, a public subnet, a security group (SSH + HTTP) and a single EC2 instance. The repo intentionally includes only the core infra modules so it is easy to read and reuse.

Project structure

terraform-aws/
├── main.tf            # wires modules together
├── variables.tf       # top-level variables
├── outputs.tf         # top-level outputs
├── README.md
└── modules/
      ├── vpc/           # creates VPC + subnet and outputs subnet id
      │   ├── main.tf
      │   └── variables.tf
      ├── security_group/# creates the SG allowing SSH/HTTP
      │   ├── main.tf
      │   └── variables.tf
      └── ec2/           # creates an EC2 instance (AMI auto-selected per region)
            ├── main.tf
            └── variables.tf

Quick start

  1. Configure AWS credentials (required for Terraform to talk to AWS):
aws configure
  1. Initialize the working directory (downloads providers and modules):
terraform init
  1. (Optional) See the execution plan:
terraform plan
  1. Apply the plan and provision resources:
terraform apply

Confirm with yes when prompted.

  1. To destroy everything provisioned by Terraform:
terraform destroy

Important notes

  • The EC2 module will automatically select a recent Amazon Linux 2 AMI for the region you're deploying to unless you override ami_id.
  • The VPC module will auto-select a valid availability zone for the configured region when availability_zone is left empty.
  • Do NOT commit terraform.tfstate or the .terraform/ directory. The included .gitignore already ignores those files.

Outputs

After a successful apply the following outputs are available:

  • vpc_id — VPC created by the VPC module
  • subnet_id — Subnet created in the VPC
  • security_group_id — Security group allowing SSH and HTTP
  • ec2_instance_id — The EC2 instance ID

Customization

  • Change variables.tf or the module-level variable files to configure region, instance type, CIDR blocks, or to provide a custom AMI.

Author

Satish Choudhary

Feel free to fork or open an issue if you want enhancements.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages