aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-01-31 14:24:47 -0800
committerclarkzjw <[email protected]>2023-01-31 14:24:47 -0800
commit55bf0526c86c88f5ae0d20bad6587c72cd91e835 (patch)
tree286340ac38a8f4558baa985fe6f364a9d8261a63 /infra/main.tf
parent0d9b8b4a4a2bb936744a338d1e7a42f2bd2272c9 (diff)
downloadzjw.social-55bf0526c86c88f5ae0d20bad6587c72cd91e835.tar.gz
add ec2, rds
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)