Creating definition for alpha and lewdlad service

This commit is contained in:
shockrah 2022-12-06 19:53:48 -08:00
parent b9ac171181
commit e830889432

View File

@ -1,59 +1,60 @@
# Alpha is our primary server that we use for bots which basically # Alpha houses all of our containerized applications
# serve services that I personally run # Essentially it is a cluster with services that we
# choose to expose to the internet in one form or another
######################### SSH KEY ############################################## # Logging Configuration for services inside the cluster
resource "aws_key_pair" "alpha_ssh" { #######################################################
key_name = var.alpha_ssh_key_name
public_key = file(var.alpha_public_key_path) resource "aws_cloudwatch_log_group" "alpha" {
name = "alpha-log"
} }
######################### files.leftcoast.space VOLUME ######################### # Alpha cluster definition
resource "aws_ebs_volume" "photo_gallery_volume" { ###########################
availability_zone = var.athens_availability_zone resource "aws_ecs_cluster" "alpha" {
size = 35 name = "alpha"
configuration {
tags = { execute_command_configuration {
Name = "Photo gallery volume" log_configuration {
Description = "Volume is to be used entirely for Photos/Video" cloud_watch_log_group_name = aws_cloudwatch_log_group.alpha.name
}
}
} }
} }
######################### clips.shockrah.xyz VOLUME ############################
resource "aws_ebs_volume" "id" {
availability_zone = "us-west-1b"
size = 35
tags = {
Name = "Clips"
Description = "Used for the clippable instance"
}
}
######################### INSTANCE CONFIGURATION ############################### # Lewdlad Service Definition
resource "aws_instance" "alpha" { ############################
ami = var.alpha_ami_id resource "aws_ecs_task_definition" "lewdlad" {
instance_type = var.alpha_instance_type family = "lewdlad-task-definition"
container_definitions = jsonencode([
key_name = var.alpha_ssh_key_name {
name = "lewdlad-container"
private_ip = "10.0.1.10" image = "registry.gitlab.com/shockrah/left-coast-server-bot:latest"
vpc_security_group_ids = [ # Literally the smallest amount that fargate will allow
aws_security_group.general_web_req.id, cpu = 256
aws_security_group.remote_ssh_rec.id memory = 512
essential = true
environment = [
{ name: DISCORD_ID, value: var.DISCORD_ID },
{ name: DISCORD_TOKEN, value: var.DISCORD_TOKEN },
{ name: AWS_API_ID, value: var.AWS_API_ID },
{ name: AWS_API_STAGE, value: var.AWS_API_STAGE },
{ name: AWS_API_REGION, value: var.AWS_API_REGION },
{ name: AWS_API_KEY, value: var.AWS_API_KEY },
{ name: DEV_GUILD_ID, value: var.DEV_GUILD_ID },
{ name: BEEHIVE_ID, value: var.BEEHIVE_ID },
] ]
subnet_id = aws_subnet.crete_subnet.id
tags = {
Name = "Alpha Host"
Description = "Docker host with chatbots mostly"
} }
])
} }
######################### ATTACHMENT FOR files.leftcoast.space ################# resource "aws_ecs_service" "lewdlad" {
resource "aws_volume_attachment" "photo_gallery_attach" { name = "lewdlad"
# hdp is for hard drive photos in this case cluster = aws_ecs_cluster.alpha.arn
device_name = "/dev/sdp" task_definition = aws_ecs_task_definition.lewdlad.arn
volume_id = aws_ebs_volume.photo_gallery_volume.id desired_count = 1
instance_id = aws_instance.alpha.id
} }