{"id":20371566,"url":"https://github.com/atulkamble/terraform-webserver-setup","last_synced_at":"2026-05-09T19:13:38.801Z","repository":{"id":228953414,"uuid":"775351917","full_name":"atulkamble/terraform-webserver-setup","owner":"atulkamble","description":"This project provides a step-by-step guide for launching, connecting to, and installing a webserver on an EC2 instance using Terraform.","archived":false,"fork":false,"pushed_at":"2025-06-08T05:35:23.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-03T13:28:07.487Z","etag":null,"topics":["aws","cli","ec2","git","iac","infrastructure-as-code","terraform"],"latest_commit_sha":null,"homepage":"http://linkedin.com/in/atuljkamble","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atulkamble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"atulkamble"}},"created_at":"2024-03-21T08:24:02.000Z","updated_at":"2025-06-08T05:35:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"53c1245b-8484-44fd-a87c-5f06778b5ea5","html_url":"https://github.com/atulkamble/terraform-webserver-setup","commit_stats":null,"previous_names":["atulkamble/terraform-webserver","atulkamble/terraform-webserver-setup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atulkamble/terraform-webserver-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fterraform-webserver-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fterraform-webserver-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fterraform-webserver-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fterraform-webserver-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulkamble","download_url":"https://codeload.github.com/atulkamble/terraform-webserver-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fterraform-webserver-setup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264785499,"owners_count":23663790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cli","ec2","git","iac","infrastructure-as-code","terraform"],"created_at":"2024-11-15T01:08:32.933Z","updated_at":"2026-05-09T19:13:38.793Z","avatar_url":"https://github.com/atulkamble.png","language":"HCL","funding_links":["https://github.com/sponsors/atulkamble"],"categories":[],"sub_categories":[],"readme":"# Terraform Web Server Setup (AWS EC2)\n\nThis project uses **Terraform** to provision an **Apache HTTP web server** on an **AWS EC2 instance** inside the default VPC. It also generates a secure SSH key pair, configures security groups, and automatically installs and starts Apache on the EC2 instance.\n\n## 🛠 Features\n\n- Deploys EC2 instance in AWS (Amazon Linux 2)\n- Installs and starts Apache HTTPD server\n- Generates and saves RSA private key securely\n- Opens port **80 (HTTP)** and **22 (SSH)** via Security Group\n- Automatically fetches the public IP of the instance\n- Lightweight deployment using `t3.medium` instance\n- Cross-platform `deploy.sh` automation script\n\n## 📁 Project Structure\n\n```bash\n.\n├── aws                     # Directory to store private key\n├── deploy.sh               # Shell script to deploy infrastructure\n├── instructions.md         # Step-by-step usage instructions\n├── main.tf                 # Terraform config for AWS EC2 setup\n├── outputs.tf              # Outputs the EC2 instance's public IP\n├── README.md               # Project overview and usage\n├── terraform.tfstate       # Terraform state file (auto-generated)\n└── terraform.tfstate.backup\n````\n\n## 🚀 Quick Start\n\n```bash\n# 1. Clone this repo\ngit clone https://github.com/yourusername/terraform-webserver-setup.git\ncd terraform-webserver-setup\n\n# 2. Run the deployment script\nchmod +x deploy.sh\n./deploy.sh\n```\n\n## 🌍 Access Web Server\n\nAfter deployment, the script will output and (on supported OS) open the web server in your default browser:\n\n```\nhttp://\u003cPublic-IP\u003e\n```\n\n## 🔐 SSH Access\n\n```bash\nchmod 400 aws/mywebserver.pem\nssh -i aws/mywebserver.pem ec2-user@\u003cPublic-IP\u003e\n```\n\n## 🧹 Destroy Infrastructure\n\nTo destroy the created infrastructure:\n\n```bash\nterraform destroy -auto-approve\n```\n\n## 📌 Requirements\n\n* AWS CLI configured with access to create EC2 resources\n* Terraform \u003e= 1.5.0\n* Bash shell (macOS/Linux)\n\n# 📝 Instructions\n\n```markdown\n# Instructions: Deploy EC2 Web Server with Terraform\n\nThis guide walks you through deploying a basic Apache web server on AWS EC2 using Terraform.\n\n---\n\n## Prerequisites\n\n- AWS account with EC2 access\n- Terraform installed (`terraform -v`)\n- AWS credentials configured via `aws configure` or environment variables\n\n---\n\n## Steps\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/yourusername/terraform-webserver-setup.git\ncd terraform-webserver-setup\n````\n\n---\n\n### 2. Make Script Executable\n\n```bash\nchmod +x deploy.sh\n```\n\n---\n\n### 3. Deploy Infrastructure\n\n```bash\n./deploy.sh\n```\n\nWhat this script does:\n\n* Removes any existing key file (`aws/mywebserver.pem`)\n* Initializes Terraform\n* Applies the infrastructure\n* Fetches the public IP\n* Opens the web page in your browser\n\n---\n\n### 4. Access Web Server\n\nOnce deployed, visit:\n\n```\nhttp://\u003cPublic-IP\u003e\n```\n\nYou should see a message like:\n\n```\nWelcome to Webserver ip-172-31-xx-xx.ec2.internal\n```\n\n---\n\n### 5. SSH into Instance (Optional)\n\n```bash\nchmod 400 aws/mywebserver.pem\nssh -i aws/mywebserver.pem ec2-user@\u003cPublic-IP\u003e\n```\n\n---\n\n### 6. Destroy Infrastructure (Optional)\n\n```bash\nterraform destroy -auto-approve\n```\n\n---\n\n## Notes\n\n* The RSA key pair is generated dynamically during deployment.\n* The private key is saved to `aws/mywebserver.pem`\n* Apache is installed and enabled on boot.\n* The AMI used is Amazon Linux 2 (`ami-0cbbe2c6a1bb2ad63`) in `us-east-1`.\n\n---\n\n## Troubleshooting\n\n* **Permission denied (publickey)**: Make sure `.pem` file has `chmod 400` and is the correct key.\n* **Instance not accessible**: Ensure security group allows inbound SSH (22) and HTTP (80) traffic.\n* **Key file not found**: Ensure `aws/` directory exists or re-run `deploy.sh`.\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fterraform-webserver-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkamble%2Fterraform-webserver-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fterraform-webserver-setup/lists"}