From 55bf0526c86c88f5ae0d20bad6587c72cd91e835 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Tue, 31 Jan 2023 14:24:47 -0800 Subject: add ec2, rds --- infra/main.tf | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 infra/main.tf (limited to 'infra/main.tf') diff --git a/infra/main.tf b/infra/main.tf new file mode 100644 index 0000000..77b8571 --- /dev/null +++ b/infra/main.tf @@ -0,0 +1,46 @@ +locals { + name = var.name +} + +data "aws_subnet" "ec2" { + filter { + name = "availability-zone" + values = [aws_db_instance.mastodon.availability_zone] + } + filter { + name = "subnet-id" + values = module.vpc.public_subnets + } +} + +resource "aws_instance" "mastodon" { + ami = data.aws_ami.debian.id + instance_type = var.ec2_instance_type + + subnet_id = data.aws_subnet.ec2.id + key_name = "framework" + + vpc_security_group_ids = [aws_security_group.backend.id] + + root_block_device { + volume_type = "gp3" + // how to resize partition and file system after resizing ebs volume + // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html + volume_size = "30" + tags = { + Name = "${local.name}-root" + } + } + + tags = { + Name = local.name + } + + lifecycle { + ignore_changes = [ami] + } +} + +resource "aws_eip" "mastodon" { + instance = aws_instance.mastodon.id +} -- cgit v1.2.3