# Terraform AWS EC2 Deployment A Terraform project that automates the deployment of EC2 instances on AWS with custom initialization scripts. This showcases Infrastructure as Code best practices using Terraform to provision and configure cloud resources. ## Prerequisites - **Terraform** >= 1.0 (download from [terraform.io](https://www.terraform.io/downloads.html)) - **AWS Account** with appropriate IAM permissions - **AWS CLI** configured with valid credentials - Basic understanding of Terraform and AWS EC2 ## Project Structure ``` . ├── README.md ├── main.tf # Primary Terraform configuration ├── variables.tf # Variable definitions ├── outputs.tf # Output values └── terraform.tfvars # Variable values (create this file) ``` ## Quick Start 1. **Clone or navigate to the project directory** ```bash cd teraform_aws ``` 2. **Initialize Terraform** ```bash terraform init ``` 3. **Create terraform.tfvars** with your configuration: ```hcl aws_region = "us-east-1" instance_type = "t2.micro" # Add other variables as needed ``` 4. **Plan the deployment** ```bash terraform plan ``` 5. **Apply the configuration** ```bash terraform apply ``` 6. **Retrieve outputs** ```bash terraform output ``` ## Features - Automated EC2 instance provisioning - Custom initialization scripts (user data) for post-launch configuration - Configurable instance types and regions - Security group management - Infrastructure state management with Terraform ## Configuration Edit `terraform.tfvars` to customize: - AWS region - Instance type - Number of instances - Custom initialization commands - Security group rules ## Outputs After successful deployment, Terraform will output: - EC2 instance IDs - Public/Private IP addresses - Security group information ## Cleanup To destroy all resources: ```bash terraform destroy ``` ## Notes - Ensure your AWS credentials are properly configured before running Terraform - Review the plan output before applying changes - Some resources may incur AWS charges - Use appropriate AMI IDs for your chosen region