aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'jinwei.me/infra/main.tf')
-rw-r--r--jinwei.me/infra/main.tf44
1 files changed, 44 insertions, 0 deletions
diff --git a/jinwei.me/infra/main.tf b/jinwei.me/infra/main.tf
new file mode 100644
index 0000000..235aba0
--- /dev/null
+++ b/jinwei.me/infra/main.tf
@@ -0,0 +1,44 @@
1locals {
2 name = var.name
3}
4
5data "aws_subnet" "ec2" {
6 filter {
7 name = "availability-zone"
8 values = [aws_db_instance.jinwei-me.availability_zone]
9 }
10 filter {
11 name = "subnet-id"
12 values = module.vpc.public_subnets
13 }
14}
15
16resource "aws_instance" "jinwei_me" {
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 tags = {
28 Name = "${local.name}-root"
29 }
30 }
31
32 tags = {
33 Name = local.name
34 }
35
36 lifecycle {
37 ignore_changes = [ami]
38 }
39}
40
41resource "aws_eip" "main" {
42 instance = aws_instance.jinwei_me.id
43}
44
Powered by cgit v1.2.3 (git 2.41.0)