Skip to content

Commit

Permalink
just everything working
Browse files Browse the repository at this point in the history
  • Loading branch information
vrglx33 committed Nov 7, 2024
1 parent b7ae327 commit c6f6c37
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 163 deletions.
2 changes: 1 addition & 1 deletion tf/iam.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
data "aws_iam_policy_document" "s3_access_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.code_bucket.arn}/*"]
resources = ["${aws_s3_bucket.lti-project-code-bucket.arn}/*"]
effect = "Allow"
}
}
Expand Down
9 changes: 4 additions & 5 deletions tf/s3.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
resource "aws_s3_bucket" "code_bucket" {
resource "aws_s3_bucket" "lti-project-code-bucket" {
bucket = "lti-project-code-bucket"
acl = "private"
}

resource "null_resource" "generate_zip" {
Expand All @@ -9,19 +8,19 @@ resource "null_resource" "generate_zip" {
}

triggers = {
always_run = "${timestamp()}"
always_run = timestamp()
}
}

resource "aws_s3_bucket_object" "backend_zip" {
bucket = aws_s3_bucket.code_bucket.bucket
bucket = aws_s3_bucket.lti-project-code-bucket.bucket
key = "backend.zip"
source = "../backend.zip"
depends_on = [null_resource.generate_zip]
}

resource "aws_s3_bucket_object" "frontend_zip" {
bucket = aws_s3_bucket.code_bucket.bucket
bucket = aws_s3_bucket.lti-project-code-bucket.bucket
key = "frontend.zip"
source = "../frontend.zip"
depends_on = [null_resource.generate_zip]
Expand Down
8 changes: 4 additions & 4 deletions tf/scripts/backend_user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ yum update -y
yum install -y docker

# Iniciar el servicio de Docker
service docker start

sudo service docker start
rm -rf /home/ec2-user/backend
# Descargar y descomprimir el archivo backend.zip desde S3
aws s3 cp s3://lti-project-code-bucket/backend.zip /home/ec2-user/backend.zip
unzip /home/ec2-user/backend.zip -d /home/ec2-user/

# Construir la imagen Docker para el backend
cd /home/ec2-user/backend
docker build -t lti-backend .
sudo docker build -t lti-backend .

# Ejecutar el contenedor Docker
docker run -d -p 8080:8080 lti-backend
sudo docker run -d -p 8080:8080 lti-backend

# Timestamp to force update
echo "Timestamp: ${timestamp}"
2 changes: 2 additions & 0 deletions tf/scripts/frontend_user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-ag
# Iniciar el servicio de Docker
service docker start


sudo rm -rf /home/ec2-user/frontend
# Descargar y descomprimir el archivo frontend.zip desde S3
aws s3 cp s3://lti-project-code-bucket/frontend.zip /home/ec2-user/frontend.zip
unzip /home/ec2-user/frontend.zip -d /home/ec2-user/
Expand Down
Loading

0 comments on commit c6f6c37

Please sign in to comment.