aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'photo.jinwei.me/infra/main.tf')
-rw-r--r--photo.jinwei.me/infra/main.tf74
1 files changed, 33 insertions, 41 deletions
diff --git a/photo.jinwei.me/infra/main.tf b/photo.jinwei.me/infra/main.tf
index aabde19..5d3a001 100644
--- a/photo.jinwei.me/infra/main.tf
+++ b/photo.jinwei.me/infra/main.tf
@@ -1,54 +1,46 @@
1terraform { 1locals {
2 required_providers { 2 name = var.name
3 hcloud = {
4 source = "hetznercloud/hcloud"
5 version = "1.36.1"
6 }
7 }
8}
9
10variable "hcloud_token" {
11 sensitive = true
12} 3}
13 4
14variable "ip_range" { 5data "aws_subnet" "ec2" {
15 default = "10.0.1.0/24" 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 }
16} 14}
17 15
18resource "hcloud_ssh_key" "framework" { 16resource "aws_instance" "jinwei_me" {
19 name = "framework" 17 ami = data.aws_ami.debian.id
20 public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILS2i5/x9r+cv2j2/SUZ2x2fgQeGnJP1I7PUHC0UdWN6 framework" 18 instance_type = var.ec2_instance_type
21}
22 19
23data "hcloud_image" "debian" { 20 subnet_id = data.aws_subnet.ec2.id
24 name = "debian-11" 21 key_name = "framework"
25}
26 22
27resource "hcloud_server" "default" { 23 vpc_security_group_ids = [aws_security_group.backend.id]
28 name = "photo"
29 image = data.hcloud_image.debian.name
30 server_type = "cpx11"
31 location = "fsn1"
32 ssh_keys = [hcloud_ssh_key.framework.id]
33 24
34 public_net { 25 root_block_device {
35 ipv4_enabled = true 26 volume_type = "gp3"
36 ipv4 = hcloud_primary_ip.primary_ip_1.id 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 }
37 } 33 }
38 delete_protection = false
39 rebuild_protection = false
40 34
41 firewall_ids = [hcloud_firewall.default.id] 35 tags = {
42} 36 Name = local.name
37 }
43 38
44resource "hcloud_primary_ip" "primary_ip_1" { 39 lifecycle {
45 name = "primary_ip_test" 40 ignore_changes = [ami]
46 datacenter = "fsn1-dc14" 41 }
47 type = "ipv4"
48 assignee_type = "server"
49 auto_delete = true
50} 42}
51 43
52resource "hcloud_firewall" "default" { 44resource "aws_eip" "jinwei-me" {
53 name = "default" 45 instance = aws_instance.jinwei_me.id
54} 46}
Powered by cgit v1.2.3 (git 2.41.0)