This Terraform project provisions an AWS VPC, public subnet, security group, EC2 instance, and an encrypted EBS volume attached to the instance. The configuration is modular, using separate modules for networking and security

terraform-aws-ec2-ebs/
├── main.tf
├── variables.tf
├── outputs.tf
├── versions.tf
├── locals.tf
├── networking/
│ ├── main.tf
│ ├── output.tf
│ └── variables.tf
└── security/
├── main.tf
├── outputs..tf
├── security_note
└── variables.tf
- Creates: VPC, public subnet, internet gateway, route table, and associations.
- Inputs: VPC CIDR, subnet CIDR, availability zone, tags, project name, environment.
- Outputs: VPC ID, public subnet ID.
- Creates: Security group(s) for EC2 instance.
- Inputs: VPC ID, project name, environment, tags.
- Outputs: Security group ID(s).
- aws_instance.web_server: EC2 instance in public subnet.
- aws_ebs_volume.data_volume: Encrypted EBS volume in same AZ as instance.
- aws_volume_attachment.data: Attaches EBS volume to EC2 instance.
Set your AWS credentials as environment variables or in your AWS CLI config.
terraform init
Edit variables.tf or use -var CLI flags to override defaults.
terraform plan
terraform apply
terraform destroy
- Tagging: All resources are tagged with common tags from locals.tf .
- EBS Volume: Encrypted by default. Size/type validated.
- Availability Zone: If not set, uses the first available AZ in the region.
- Security: Security group allows SSH from
allowed_ssh_cidr.
- More modules for private subnets, NAT gateways, etc will be added .
- Add outputs can be added for more resource attributes.
- To integrate with other AWS services as needed.