blog.shockrah.xyz working at an infrastructure level now

Also updated the image so that it has the right baseURL
which gets configured during the service build ( Hugo )
This commit is contained in:
shockrah 2023-02-10 22:07:26 -08:00
parent 53267daf99
commit 904b730362
4 changed files with 75 additions and 1 deletions

View File

@ -33,7 +33,6 @@ http {
server {
server_name "blog.shockrah.xyz";
location / {
return 200 'Visiting blog.shockrah.xyz';
root /var/www/blog.shockrah.xyz;
}
}

View File

@ -26,6 +26,9 @@ resource "aws_lb_target_group" "shockrah_xyz" {
protocol = "HTTP"
target_type = "ip"
vpc_id = aws_vpc.athens_vpc.id
health_check {
interval = 60
}
}
resource "aws_lb_listener" "https" {

67
infra/nginx.tf Normal file
View File

@ -0,0 +1,67 @@
# This nginx service will replace the beta host so that
# we leverage nginx as a reverse proxy in fargate instead
resource "aws_ecs_task_definition" "beta" {
family = "${var.athens_prefix}-beta"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
execution_role_arn = aws_iam_role.alpha_iam_role.arn
cpu = 256
memory = 512
container_definitions = jsonencode([
{
name = "${var.athens_prefix}-beta-container"
image = "805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest"
cpu = 256
memory = 512
essential = true
portMappings = [
# blog.shockrah.xyz
{
containerPort = var.shockrah_xyz_nginx_port,
hostPort = var.shockrah_xyz_nginx_port
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = aws_cloudwatch_log_group.alpha.name
awslogs-region = "us-west-1"
awslogs-stream-prefix = "beta-container"
}
}
}
])
tags = {
Name = "${var.athens_prefix}-beta-task-def-container"
Description = "Reverse proxy for all static content"
}
}
resource "aws_ecs_service" "beta_reverse_proxy" {
name = "${var.athens_prefix}-beta-reverse-proxy"
cluster = aws_ecs_cluster.alpha.id
task_definition = aws_ecs_task_definition.beta.arn
desired_count = 1
launch_type = "FARGATE"
load_balancer {
target_group_arn = aws_lb_target_group.shockrah_xyz.arn
container_name = "${var.athens_prefix}-beta-container"
container_port = var.shockrah_xyz_nginx_port
}
network_configuration {
assign_public_ip = true
subnets = [
aws_subnet.delphi.id,
aws_subnet.crete_subnet.id,
]
security_groups = [
aws_security_group.ecs_web_ingress.id,
aws_security_group.base_ecs.id,
]
}
}

View File

@ -38,6 +38,11 @@ locals {
{ name = "freechat.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] },
{ name = "resume.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] },
{ name = "www.shockrah.xyz", records = [ aws_eip.beta_eip.public_ip ] },
{
name = "blog.shockrah.xyz"
type = "CNAME"
records = [ aws_lb.alpha.dns_name ]
},
]
}