-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from mihai-satmarean/feature/55-create-vpc-and…
…-implement-ec2-into-local-branch Feature/55 create vpc and implement ec2 into local branch
- Loading branch information
Showing
30 changed files
with
717 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Terraform apply | ||
run-name: ${{ github.actor }} is deploying on AWS 🚀 | ||
on: | ||
push: | ||
branches: | ||
- 55-create-vpc-and-implement-ec2-into-local-branch | ||
jobs: | ||
Deploy-AWS-EC2: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_RADU }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_RADU }} | ||
aws-region: eu-central-1 | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Deploy Infrastructure | ||
run: | | ||
cd terraform/terraform-modules/tf-ec2-module/ | ||
terraform init | ||
terraform destroy -auto-approve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Project Title | ||
|
||
A short description of your project, what it does, and why it's useful. | ||
|
||
--- | ||
|
||
## Table of Contents | ||
|
||
- [About](#about) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
- [Contact](#contact) | ||
|
||
--- | ||
|
||
## About | ||
|
||
Provide a more detailed description of your project here. You can include: | ||
|
||
- The main goal of the project | ||
- Technologies used | ||
- Key features | ||
- Screenshots (if applicable) | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
### Prerequisites | ||
|
||
- List any software or tools required to run the project (e.g., Node.js, Python, etc.) | ||
|
||
### Steps | ||
|
||
1. Clone the repository | ||
```bash | ||
git clone https://github.com/your-username/project-name.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: Start Python web server | ||
hosts: all | ||
become: yes | ||
tasks: | ||
- name: Ensure Python is installed | ||
apt: | ||
name: python3 | ||
state: present | ||
|
||
- name: Start Python web server | ||
command: python3 -m http.server | ||
args: | ||
chdir: /var/www/html | ||
async: 3600 | ||
poll: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Restart NGINX | ||
systemd: | ||
name: nginx | ||
state: restarted | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: Install NGINX | ||
apt: | ||
name: nginx | ||
state: present | ||
update_cache: yes | ||
become: true | ||
|
||
- name: Create NGINX configuration | ||
template: | ||
src: nginx.conf.j2 | ||
dest: /etc/nginx/nginx.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
notify: Restart NGINX | ||
become: true | ||
|
||
- name: Create load balancer configuration | ||
template: | ||
src: load-balancer.conf.j2 | ||
dest: /etc/nginx/conf.d/load-balancer.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
notify: Restart NGINX | ||
become: true | ||
|
||
- name: Ensure NGINX service is running | ||
systemd: | ||
name: nginx | ||
state: started | ||
enabled: yes | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
upstream backend { | ||
{% for server in backend_servers %} | ||
server {{ server.host }}:{{ server.port }} weight={{ server.weight | default(1) }}; | ||
{% endfor %} | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name {{ server_name }}; | ||
|
||
location / { | ||
proxy_pass http://backend; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
user www-data; | ||
worker_processes auto; | ||
pid /run/nginx.pid; | ||
|
||
events { | ||
worker_connections 768; | ||
} | ||
|
||
http { | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
ssl_protocols TLSv1.2 TLSv1.3; | ||
ssl_prefer_server_ciphers on; | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
server_name: example.com | ||
backend_servers: | ||
- host: 192.168.1.10 | ||
port: 8080 | ||
weight: 3 | ||
- host: 192.168.1.11 | ||
port: 8080 | ||
weight: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
# sciitdevops | ||
|
||
## Project Overview | ||
This repository serves as the base for the DevOps training program. It is designed to help participants advance towards the final goal of deploying a web site/app using all the tooling and practices covered in the DevOps training. | ||
|
||
## How to Use This Repository | ||
|
||
### Branching Strategy | ||
- Each participant is encouraged to create their own branch from the main branch. | ||
- Use your branch to work on exercises, projects, and any custom implementations related to the training. | ||
- Regularly merge changes from the main branch to keep your branch up to date. | ||
|
||
### Repository Structure | ||
- The repository will contain specific folders for different exercises and projects. | ||
- **Terraform Code:** Store Terraform scripts for managing AWS and Azure resources in the `terraform/` directory. | ||
- **CI/CD Configuration:** Store Jenkins, GitHub Actions, or other CI/CD configuration files in the `ci-cd/` directory. | ||
- **Application Code:** Store the web application code in the `app/` directory. | ||
- **Documentation:** Use the `docs/` directory for any additional documentation or notes. | ||
|
||
## Getting Started | ||
1. **Clone the Repository:** | ||
```bash | ||
git clone [email protected]:mihai-satmarean/sciitdevops.git | ||
``` | ||
|
||
2. **Create a Branch:** | ||
```bash | ||
git checkout -b your-branch-name | ||
``` | ||
|
||
3. **Work on Exercises and Projects:** | ||
- Use the provided directories to organize your work. | ||
- Commit and push your changes regularly. | ||
|
||
4. **Collaborate and Review:** | ||
- Collaborate with other participants by reviewing and discussing each other's work. | ||
- Use pull requests to propose changes to the main branch. | ||
|
||
## Final Goal | ||
The final goal of this training is to deploy a fully functional web site/app using the DevOps tools and practices learned throughout the course. This includes: | ||
- Infrastructure provisioning with Terraform | ||
- CI/CD pipelines with Jenkins or GitHub Actions | ||
- Application deployment and monitoring | ||
|
||
By following this structure and utilizing the repository, participants will gain hands-on experience and work towards achieving the final goal of the training. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "aws_s3_bucket" "bucket" { | ||
bucket = var.bucket_name | ||
acl = var.acl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "aws_s3_bucket" "bucket" { | ||
bucket = var.bucket_name | ||
acl = var.acl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
TERRAFORM AWS S3 BUCKETS MODULE | ||
|
||
To keep our work well structured, ww will use separate folders for each type of resource. In our case, for modules we will use "terraform-modules". | ||
|
||
The structure of this project is: | ||
Main folder - terraform | ||
Subfolder - terraform-modules | ||
Subfolder - tf-s3-module | ||
|
||
In the "terraform" folder we have 2 files: | ||
1. readme.md - this is the file that contains valuable information about the project | ||
2. s3.tf - this is the file that we will use to create our AWS S3 buckets. In this file we need to change the "name" and "owner" vars to our desire. | ||
Also, we can specify more variables (ex. acl, force_destroy, etc) or use the default ones in the module folder. | ||
|
||
In the "terraform-modules" folder we will create separate folders for each module. The first one is the AWS S3 Module, "tf-s3-module", that contains | ||
the code for a module that we will use to manage the AWS S3 buckets in an easy and organized way, using variables. The folder contains 4 files: | ||
1. inputs.tf - this file contains the variables we can use with our module | ||
2. outputs.tf - this file contains the output variables we need from the job execution output | ||
3. versions.tf - this file contains the module version as well as the minimum required version (using an older version may lead to errors as variables may not be implemented, etc.) | ||
4. main.tf - this is the main module file | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module "s3_bucket" { | ||
source = "git::https://github.com/mihai-satmarean/sciitdevops/blob/main/terraform/terraform-modules/tf-s3-modules/" # se va modifica in functie de locatia modulului in GitHub | ||
|
||
name = "nume" # numele tag-ului ce il atribuim resursei | ||
owner = "owner" # numele owner-ului resursei | ||
|
||
s3_bucket_names = ["mariusb_devops_bucket1"] | ||
acl = "private" | ||
force_destroy = false | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# Ignore variables files | ||
*.auto.tfvars | ||
|
||
# Ignore override files | ||
*.tfoverride | ||
|
||
# Ignore environment-specific files | ||
.envrc | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
|
||
# Ignore Terraform state files and providers | ||
terraform.tfstate | ||
terraform.lock.hcl | ||
|
||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* |
Oops, something went wrong.