A simple Terraform project that provisions an AWS EC2 instance with SSH and HTTP access.
- Terraform (>= 0.14)
- AWS account with appropriate permissions
- AWS CLI configured with your credentials
git clone https://github.com/yourusername/aws-ec2-terraform-starter.git
cd aws-ec2-terraform-starter
Create a key pair named terraform-test
in the AWS console or using the AWS CLI:
aws ec2 create-key-pair --key-name terraform-test --query 'KeyMaterial' --output text > terraform-test.pem
chmod 400 terraform-test.pem
terraform init
terraform plan
terraform apply
When prompted, type yes
to confirm.
Once provisioning is complete, you can SSH into your instance:
ssh -i terraform-test.pem ec2-user@<public-ip>
Replace <public-ip>
with the public IP address shown in the Terraform output.
- EC2 instance (t2.micro)
- Security group allowing SSH (port 22) and HTTP (port 80) access
To destroy all resources created by Terraform:
terraform destroy
When prompted, type yes
to confirm.
MIT