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" { # Lewdlad Service Definition
availability_zone = "us-west-1b" ############################
size = 35 resource "aws_ecs_task_definition" "lewdlad" {
tags = { family = "lewdlad-task-definition"
Name = "Clips" container_definitions = jsonencode([
Description = "Used for the clippable instance" {
} name = "lewdlad-container"
image = "registry.gitlab.com/shockrah/left-coast-server-bot:latest"
# Literally the smallest amount that fargate will allow
cpu = 256
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 },
]
}
])
} }
######################### INSTANCE CONFIGURATION ############################### resource "aws_ecs_service" "lewdlad" {
resource "aws_instance" "alpha" { name = "lewdlad"
ami = var.alpha_ami_id cluster = aws_ecs_cluster.alpha.arn
instance_type = var.alpha_instance_type task_definition = aws_ecs_task_definition.lewdlad.arn
desired_count = 1
key_name = var.alpha_ssh_key_name
private_ip = "10.0.1.10"
vpc_security_group_ids = [
aws_security_group.general_web_req.id,
aws_security_group.remote_ssh_rec.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_volume_attachment" "photo_gallery_attach" {
# hdp is for hard drive photos in this case
device_name = "/dev/sdp"
volume_id = aws_ebs_volume.photo_gallery_volume.id
instance_id = aws_instance.alpha.id
} }