aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'infra/main.tf')
-rw-r--r--infra/main.tf46
1 files changed, 46 insertions, 0 deletions
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 @@
1locals {
2 name = var.name
3}
4
5data "aws_subnet" "ec2" {
6 filter {
7 name = "availability-zone"
8 values = [aws_db_instance.mastodon.availability_zone]
9 }
10 filter {
11 name = "subnet-id"
12 values = module.vpc.public_subnets
13 }
14}
15
16resource "aws_instance" "mastodon" {
17 ami = data.aws_ami.debian.id
18 instance_type = var.ec2_instance_type
19
20 subnet_id = data.aws_subnet.ec2.id
21 key_name = "framework"
22
23 vpc_security_group_ids = [aws_security_group.backend.id]
24
25 root_block_device {
26 volume_type = "gp3"
27 // how to resize partition and file system after resizing ebs volume
28 // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html
29 volume_size = "30"
30 tags = {
31 Name = "${local.name}-root"
32 }
33 }
34
35 tags = {
36 Name = local.name
37 }
38
39 lifecycle {
40 ignore_changes = [ami]
41 }
42}
43
44resource "aws_eip" "mastodon" {
45 instance = aws_instance.mastodon.id
46}
Powered by cgit v1.2.3 (git 2.41.0)