From 3ef52017c19a7670b612664e2fd52b532b3e53d8 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 29 Oct 2022 15:50:40 -0700 Subject: [PATCH] New version of alpha named atlas ready for provisioning --- infra/alpha.tf | 7 +++++ infra/atlas.tf | 66 +++++++++++++++++++++++++++++++++++++++++++++ infra/input-vars.tf | 25 +++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 infra/atlas.tf diff --git a/infra/alpha.tf b/infra/alpha.tf index 3c0f1a6..ccf9f8b 100644 --- a/infra/alpha.tf +++ b/infra/alpha.tf @@ -1,11 +1,13 @@ # Alpha is our primary server that we use for bots which basically # serve services that I personally run +######################### SSH KEY ############################################## resource "aws_key_pair" "alpha_ssh" { key_name = var.alpha_ssh_key_name public_key = file(var.alpha_public_key_path) } +######################### files.leftcoast.space VOLUME ######################### resource "aws_ebs_volume" "photo_gallery_volume" { availability_zone = var.athens_availability_zone size = 35 @@ -16,6 +18,7 @@ resource "aws_ebs_volume" "photo_gallery_volume" { } } +######################### clips.shockrah.xyz VOLUME ############################ resource "aws_ebs_volume" "id" { availability_zone = "us-west-1b" size = 35 @@ -25,6 +28,7 @@ resource "aws_ebs_volume" "id" { } } +######################### INSTANCE CONFIGURATION ############################### resource "aws_instance" "alpha" { ami = var.alpha_ami_id instance_type = var.alpha_instance_type @@ -44,9 +48,12 @@ resource "aws_instance" "alpha" { } +######################### 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 } + + diff --git a/infra/atlas.tf b/infra/atlas.tf new file mode 100644 index 0000000..3798b69 --- /dev/null +++ b/infra/atlas.tf @@ -0,0 +1,66 @@ +# This is the continuation of the old alpha host but with much cleaner code +# and less manual infra setup involved. Key differences are that block storage +# is now completely kept in this module instead of yolo'd out like before. + +######################### SSH KEY ############################################## +resource "aws_key_pair" "atlas_ssh" { + key_name = var.atlas_ssh_key_name + public_key = file(var.atlas_public_key_path) +} + +######################### files.leftcoast.space VOLUME ######################### +resource "aws_ebs_volume" "files-leftcoast-space" { + availability_zone = var.athens_availability_zone + size = 30 + + tags = { + Name = "files.leftcoast.space-ebs" + Description = "Volume is to be used entirely for Photos/Video" + } +} + +######################### clips.shockrah.xyz VOLUME ############################ +resource "aws_ebs_volume" "clips-shockrah-xyz" { + availability_zone = var.athens_availability_zone + size = 30 + + tags = { + Name = "clips.shockrah.xyz-ebs" + Description = "Used for the clippable instance" + } +} + +######################### ATTACHMENT FOR files.leftcoast.space ################# +resource "aws_volume_attachment" "files-leftcoast-space" { + device_name = "/dev/sdf" + volume_id = aws_ebs_volume.files-leftcoast-space.id + instance_id = aws_instance.atlas.id +} + + +######################### ATTACHMENT FOR clips.shockrah.xyz #################### +resource "aws_volume_attachment" "clips-shockrah-xyz" { + device_name = "/dev/sdg" + volume_id = aws_ebs_volume.clips-shockrah-xyz.id + instance_id = aws_instance.atlas.id +} + +######################### INSTANCE CONFIGURATION ############################### +resource "aws_instance" "atlas" { + ami = var.atlas_ami_id + instance_type = var.atlas_instance_type + + key_name = var.atlas_ssh_key_name + + private_ip = "10.0.1.20" + 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 = "Atlas Host" + Description = "Simple Docker host for some personal stuff" + } + +} diff --git a/infra/input-vars.tf b/infra/input-vars.tf index 021cacf..afb9896 100644 --- a/infra/input-vars.tf +++ b/infra/input-vars.tf @@ -43,6 +43,31 @@ variable "alpha_ami_id" { type = string } +######################### Alpha variables ###################################### + +variable "atlas_ssh_key_name" { + description = "Atlas ssh keyname" + type = string + sensitive = true +} + +variable "atlas_public_key_path" { + description = "Atlas' key filepath on local disk" + type = string + sensitive = true +} + +variable "atlas_instance_type" { + description = "Atlas instance type larger size for docker" + type = string + sensitive = true +} + +variable "atlas_ami_id" { + description = "AMI type for the docker host" + type = string +} + ######################### Beta variables variable "beta_ssh_key_name" { description = "SSH Key name for static web host"