This project demonstrates how to deploy a simple web application (such as Jenkins) on an AWS EC2 instance and make it accessible from outside AWS. It includes steps for provisioning resources, configuring the server, and accessing the application via a public URL.
- Deployment of Jenkins, a popular CI/CD tool, on an EC2 instance.
- Secure and scalable infrastructure setup.
- Accessing the application through a public domain or IP.
- Detailed configuration instructions.
- AWS Account: Ensure you have an active AWS account.
- AWS CLI: Installed and configured on your local machine.
- EC2 Key Pair: Create a key pair in AWS to securely access the EC2 instance.
- Security Group: Configure security group rules to allow HTTP and SSH traffic.
- Basic Knowledge of Jenkins: Familiarity with its functionality is helpful but not mandatory.
- Log in to your AWS Management Console.
- Navigate to EC2 and click Launch Instances.
- Choose an Amazon Machine Image (AMI), e.g., Ubuntu 22.04 LTS.
- Select an instance type (e.g., t2.micro for free tier).
- Configure the following:
- Key Pair: Select an existing one or create a new key pair.
- Security Group:
- Allow HTTP (port 80) and SSH (port 22).
- Allow the application's port (e.g., 8080 for Jenkins).
- Launch the instance.
Obtain the public IP or DNS of your EC2 instance from the AWS Console. Use the following command to connect:
ssh -i <your-key.pem> ubuntu@<your-ec2-public-ip>
- Update the package manager:
sudo apt update && sudo apt upgrade -y
- Install Java (Jenkins requires Java 17 or higher):
sudo apt install openjdk-17-jdk -y
- Add the Jenkins repository:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null sudo apt update
- Install Jenkins:
sudo apt install jenkins -y
- Start and enable the Jenkins service:
sudo systemctl start jenkins sudo systemctl enable jenkins
Allow inbound traffic to Jenkins' default port (8080):
- Go to EC2 > Security Groups in the AWS Console.
- Edit the inbound rules and add:
- Protocol: TCP
- Port: 8080
- Source: 0.0.0.0/0 (For public access).
- Open your web browser.
- Navigate to:
http://<your-ec2-public-ip>:8080
- Unlock Jenkins:
- Security: Avoid using
0.0.0.0/0
in production environments. Restrict access to trusted IP ranges. - Scaling: For scalability, consider using AWS Elastic Load Balancer (ELB) and Auto Scaling Groups.
- Persistence: Use Amazon EBS for storing application data persistently.
├── README.md # Project documentation
├── scripts/ # Bash scripts for automation (optional)
└── diagrams/ # Architecture diagrams (optional)
- Automate deployment using Infrastructure-as-Code (IaC) tools like Terraform.
- Use AWS Application Load Balancer (ALB) for high availability.
- Secure application with HTTPS using Let's Encrypt.
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any issues or suggestions, feel free to create an issue in this repository or contact me directly.