Skip to content

Commit

Permalink
added terraform config
Browse files Browse the repository at this point in the history
  • Loading branch information
HarounAlarabi committed Feb 24, 2024
1 parent 595712c commit e25ba7d
Show file tree
Hide file tree
Showing 22 changed files with 2,485 additions and 64 deletions.
41 changes: 20 additions & 21 deletions .github/workflows/frontend-s3-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Frontend S3 Deploy

on:
push:
branches:
Expand All @@ -14,7 +13,7 @@ jobs:
uses: actions/checkout@v2

- name: Set Up Node.js

uses: actions/setup-node@v3
with:
node-version: 14
Expand All @@ -37,7 +36,7 @@ jobs:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -48,25 +47,25 @@ jobs:

- name : build and deploy
run: |
cd client
cd client
npm install
npm run build
aws s3 sync build/ s3://cyf-videos --delete

1 change: 1 addition & 0 deletions client/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
.vscode/


.terraform
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"git.ignoreLimitWarning": true
"git.ignoreLimitWarning": true,
"editor.defaultFormatter": "vscode.css-language-features",
"editor.defaultFoldingRangeProvider": "ms-azuretools.vscode-azureterraform"
}
62 changes: 62 additions & 0 deletions EC2-TF-config/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions EC2-TF-config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
resource "aws_instance" "videso-tf" {
ami = "ami-0e5f882be1900e43b"
instance_type = "t2.micro"
key_name = aws_key_pair.vid-key-tf.key_name

tags = {
Name = "videso-tf"
}
vpc_security_group_ids = [aws_security_group.TF_SG.id]
}


resource "aws_security_group" "TF_SG" {
name = "security_group_TF"
description = "Allow TLS EC2 traffic to the instance"
vpc_id = "vpc-0648145579e063003"

tags = {
Name = "TF_SG"
}

ingress {
description = "HTTPS"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
ingress {
description = "HTTP"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}

ingress {
description = "SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
}



resource "tls_private_key" "rsa" {
algorithm = "RSA"
rsa_bits = 4096
}

resource "local_file" "vid-key-tf" {
content = tls_private_key.rsa.private_key_pem
filename = "vid-key-tf.pem"
}

resource "aws_key_pair" "vid-key-tf" {
key_name = "vid-key-tf"
public_key = tls_private_key.rsa.public_key_openssh
}
Empty file added EC2-TF-config/securitygroup.tf
Empty file.
Loading

0 comments on commit e25ba7d

Please sign in to comment.