This repository contains Terraform scripts and Ansible playbooks for automating the deployment of an Apache web server on an AWS EC2 instance.
This project demonstrates Infrastructure-as-Code (IaC) principles by using Terraform to provision an EC2 instance and Ansible to configure and deploy an Apache web application stack.
- Terraform: For provisioning the AWS EC2 instance and related infrastructure.
- Ansible: For automating the installation, configuration, and deployment of the Apache web server.
- AWS EC2: For hosting the web server.
- Git: For version control.
Before you begin, ensure you have the following installed and configured:
- AWS CLI: Configured with your AWS credentials.
- Terraform: Installed and configured.
- Ansible: Installed and configured.
- Git: Installed and configured.
- An AWS account.
- An SSH key pair for accessing the EC2 instance.
-
Clone the Repository:
git clone [https://github.com/krithikakartik17/Apache-Web-Server.git](https://www.google.com/search?q=https://github.com/krithikakartik17/Apache-Web-Server.git) cd Apache-Web-Server
-
Terraform Deployment:
-
Initialize Terraform:
terraform init
-
Apply the Terraform configuration:
terraform apply
-
This will create an EC2 instance. You can view the public IP address of your EC2 instance on AWS Console.
-
-
Ansible Deployment:
-
Update the Ansible inventory file (
hosts) with the public IP address of your EC2 instance. -
Ensure your SSH private key path is correct in the
hostsfile. -
Run the Ansible playbook:
ansible-playbook -i hosts install_apache.yml
-
This will install and configure Apache on the EC2 instance and deploy a basic
index.htmlfile.
-
-
Access the Web Server:
- Open a web browser and navigate to the public IP address of your EC2 instance.