Skip to content

Commit db385ed

Browse files
authored
infra(aggregation mode): add terraform setup (#2191)
1 parent 498f243 commit db385ed

18 files changed

Lines changed: 1264 additions & 0 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ circuit_js
4141

4242
# Reports
4343
docs/dead_links_report.txt
44+
45+
**/.terraform
46+
terraform.tfstate
47+
terraform.tfstate.backup
48+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#cloud-config
2+
hostname: ${hostname}
3+
fqdn: ${hostname}
4+
manage_etc_hosts: true
5+
6+
users:
7+
- name: app
8+
shell: /bin/bash
9+
ssh_authorized_keys:
10+
- ${ssh_public_key}
11+
- name: admin
12+
shell: /bin/bash
13+
sudo: ALL=(ALL) NOPASSWD:ALL
14+
ssh_authorized_keys:
15+
- ${ssh_public_key}
16+
17+
package_update: true
18+
package_upgrade: true
19+
20+
packages:
21+
- ca-certificates
22+
- curl
23+
- wget
24+
- gnupg
25+
- vim
26+
- git
27+
- zip
28+
- unzip
29+
- openssl
30+
- libssl-dev
31+
- build-essential
32+
- rsyslog
33+
- htop
34+
- rsync
35+
- pkg-config
36+
- locales
37+
- ufw
38+
39+
write_files:
40+
- path: /etc/environment
41+
content: |
42+
LANG=en_US.UTF-8
43+
LC_ALL=C
44+
LANGUAGE=en_US.UTF-8
45+
LC_TYPE=en_US.UTF-8
46+
LC_CTYPE=en_US.UTF-8
47+
48+
runcmd:
49+
- loginctl enable-linger app
50+
# Tailscale installation https://tailscale.com/kb/1293/cloud-init
51+
- curl -fsSL https://tailscale.com/install.sh | sh
52+
- tailscale up --ssh --advertise-tags=tag:server --auth-key=${tailscale_auth_key}
53+
- tailscale set --auto-update
54+
- sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
55+
- locale-gen
56+
- ufw enable
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#cloud-config
2+
hostname: ${hostname}
3+
fqdn: ${hostname}
4+
manage_etc_hosts: true
5+
6+
users:
7+
- name: app
8+
shell: /bin/bash
9+
ssh_authorized_keys:
10+
- ${ssh_public_key}
11+
- name: admin
12+
shell: /bin/bash
13+
sudo: ALL=(ALL) NOPASSWD:ALL
14+
ssh_authorized_keys:
15+
- ${ssh_public_key}
16+
17+
package_update: true
18+
package_upgrade: true
19+
20+
packages:
21+
- ca-certificates
22+
- curl
23+
- wget
24+
- gnupg
25+
- vim
26+
- git
27+
- zip
28+
- unzip
29+
- openssl
30+
- libssl-dev
31+
- build-essential
32+
- rsyslog
33+
- htop
34+
- rsync
35+
- pkg-config
36+
- locales
37+
38+
write_files:
39+
- path: /etc/environment
40+
content: |
41+
LANG=en_US.UTF-8
42+
LC_ALL=C
43+
LANGUAGE=en_US.UTF-8
44+
LC_TYPE=en_US.UTF-8
45+
LC_CTYPE=en_US.UTF-8
46+
47+
runcmd:
48+
- loginctl enable-linger app
49+
# Tailscale installation https://tailscale.com/kb/1293/cloud-init
50+
- curl -fsSL https://tailscale.com/install.sh | sh
51+
- tailscale up --ssh --advertise-tags=tag:server --auth-key=${tailscale_auth_key}
52+
- tailscale set --auto-update
53+
- sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
54+
- locale-gen
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#cloud-config
2+
hostname: ${hostname}
3+
fqdn: ${hostname}
4+
manage_etc_hosts: true
5+
6+
users:
7+
- name: app
8+
shell: /bin/bash
9+
ssh_authorized_keys:
10+
- ${ssh_public_key}
11+
- name: admin
12+
shell: /bin/bash
13+
sudo: ALL=(ALL) NOPASSWD:ALL
14+
ssh_authorized_keys:
15+
- ${ssh_public_key}
16+
17+
package_update: true
18+
package_upgrade: true
19+
20+
packages:
21+
- ca-certificates
22+
- curl
23+
- wget
24+
- gnupg
25+
- vim
26+
- git
27+
- zip
28+
- unzip
29+
- openssl
30+
- libssl-dev
31+
- build-essential
32+
- rsyslog
33+
- htop
34+
- rsync
35+
- pkg-config
36+
- locales
37+
38+
write_files:
39+
- path: /etc/environment
40+
content: |
41+
LANG=en_US.UTF-8
42+
LC_ALL=C
43+
LANGUAGE=en_US.UTF-8
44+
LC_TYPE=en_US.UTF-8
45+
LC_CTYPE=en_US.UTF-8
46+
47+
runcmd:
48+
- loginctl enable-linger app
49+
# Tailscale installation https://tailscale.com/kb/1293/cloud-init
50+
- curl -fsSL https://tailscale.com/install.sh | sh
51+
- tailscale up --ssh --advertise-tags=tag:server --auth-key=${tailscale_auth_key}
52+
- tailscale set --auto-update
53+
- sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
54+
- locale-gen

infra/aggregation_mode/terraform/environments/hoodi/.terraform.lock.hcl

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# Init
3+
4+
```shell
5+
source .env && terraform init -migrate-state \
6+
-backend-config="bucket=${TFSTATE_BUCKET}" \
7+
-backend-config="key=${TFSTATE_KEY}" \
8+
-backend-config="region=${TFSTATE_REGION}"
9+
```
10+
11+
# Plan
12+
13+
```shell
14+
source .env && terraform plan
15+
```
16+
17+
# Apply
18+
19+
```shell
20+
source .env && terraform apply
21+
```
22+
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# AWS Provider Configuration
2+
provider "aws" {
3+
region = var.aws_region
4+
}
5+
6+
# Scaleway Provider Configuration
7+
provider "scaleway" {
8+
}
9+
10+
# Tailscale Provider Configuration
11+
provider "tailscale" {
12+
}
13+
14+
# Postgres Monitor (EC2)
15+
module "postgres_monitor" {
16+
source = "../../modules/ec2"
17+
18+
ec2_instance_name = var.postgres_monitor_instance_name
19+
ec2_hostname = var.postgres_monitor_hostname
20+
ec2_instance_type = var.postgres_monitor_instance_type
21+
ec2_ssh_key_name = var.postgres_monitor_ssh_key_name
22+
ec2_ssh_public_key_path = var.ssh_public_key_path_aws
23+
ec2_cloud_init_template_path = var.postgres_monitor_cloud_init_template_path
24+
ec2_root_volume_size = var.postgres_monitor_root_volume_size
25+
ec2_tailscale_key_expiry = var.tailscale_key_expiry
26+
ec2_tailscale_tags = var.tailscale_tags
27+
28+
ec2_tags = var.common_tags
29+
}
30+
31+
# Postgres Primary (Elastic Metal / Scaleway Bare Metal)
32+
module "postgres_primary" {
33+
source = "../../modules/elastic_metal"
34+
35+
elastic_metal_zone = var.postgres_primary_zone
36+
elastic_metal_offer_name = var.postgres_primary_offer_name
37+
elastic_metal_subscription_period = var.subscription_period
38+
elastic_metal_server_name = var.postgres_primary_server_name
39+
elastic_metal_hostname = var.postgres_primary_hostname
40+
elastic_metal_description = var.postgres_primary_description
41+
elastic_metal_ssh_key_name = var.postgres_primary_ssh_key_name
42+
elastic_metal_ssh_public_key_path = var.ssh_public_key_path_scaleway
43+
elastic_metal_cloud_init_template_path = var.postgres_primary_cloud_init_template_path
44+
elastic_metal_os_id = var.os_id
45+
elastic_metal_tailscale_key_expiry = var.tailscale_key_expiry
46+
elastic_metal_tailscale_tags = var.tailscale_tags
47+
elastic_metal_tags = var.postgres_primary_tags
48+
}
49+
50+
# Postgres Secondary (Elastic Metal / Scaleway Bare Metal)
51+
module "postgres_secondary" {
52+
source = "../../modules/elastic_metal"
53+
54+
elastic_metal_zone = var.postgres_secondary_zone
55+
elastic_metal_offer_name = var.postgres_secondary_offer_name
56+
elastic_metal_subscription_period = var.subscription_period
57+
elastic_metal_server_name = var.postgres_secondary_server_name
58+
elastic_metal_hostname = var.postgres_secondary_hostname
59+
elastic_metal_description = var.postgres_secondary_description
60+
elastic_metal_ssh_key_name = var.postgres_secondary_ssh_key_name
61+
elastic_metal_ssh_public_key_path = var.ssh_public_key_path_scaleway
62+
elastic_metal_cloud_init_template_path = var.postgres_secondary_cloud_init_template_path
63+
elastic_metal_os_id = var.os_id
64+
elastic_metal_tailscale_key_expiry = var.tailscale_key_expiry
65+
elastic_metal_tailscale_tags = var.tailscale_tags
66+
elastic_metal_tags = var.postgres_secondary_tags
67+
}
68+
69+
# Gateway Primary (Elastic Metal / Scaleway Bare Metal)
70+
module "gateway_primary" {
71+
source = "../../modules/elastic_metal"
72+
73+
elastic_metal_zone = var.gateway_primary_zone
74+
elastic_metal_offer_name = var.gateway_primary_offer_name
75+
elastic_metal_subscription_period = var.subscription_period
76+
elastic_metal_server_name = var.gateway_primary_server_name
77+
elastic_metal_hostname = var.gateway_primary_hostname
78+
elastic_metal_description = var.gateway_primary_description
79+
elastic_metal_ssh_key_name = var.gateway_primary_ssh_key_name
80+
elastic_metal_ssh_public_key_path = var.ssh_public_key_path_scaleway
81+
elastic_metal_cloud_init_template_path = var.gateway_primary_cloud_init_template_path
82+
elastic_metal_os_id = var.os_id
83+
elastic_metal_tailscale_key_expiry = var.tailscale_key_expiry
84+
elastic_metal_tailscale_tags = var.tailscale_tags
85+
elastic_metal_tags = var.gateway_primary_tags
86+
}
87+
88+
# Gateway Secondary (Elastic Metal / Scaleway Bare Metal)
89+
module "gateway_secondary" {
90+
source = "../../modules/elastic_metal"
91+
92+
elastic_metal_zone = var.gateway_secondary_zone
93+
elastic_metal_offer_name = var.gateway_secondary_offer_name
94+
elastic_metal_subscription_period = var.subscription_period
95+
elastic_metal_server_name = var.gateway_secondary_server_name
96+
elastic_metal_hostname = var.gateway_secondary_hostname
97+
elastic_metal_description = var.gateway_secondary_description
98+
elastic_metal_ssh_key_name = var.gateway_secondary_ssh_key_name
99+
elastic_metal_ssh_public_key_path = var.ssh_public_key_path_scaleway
100+
elastic_metal_cloud_init_template_path = var.gateway_secondary_cloud_init_template_path
101+
elastic_metal_os_id = var.os_id
102+
elastic_metal_tailscale_key_expiry = var.tailscale_key_expiry
103+
elastic_metal_tailscale_tags = var.tailscale_tags
104+
elastic_metal_tags = var.gateway_secondary_tags
105+
}
106+
107+
# Metrics Server (Elastic Metal / Scaleway Bare Metal)
108+
module "metrics" {
109+
source = "../../modules/elastic_metal"
110+
111+
elastic_metal_zone = var.metrics_server_zone
112+
elastic_metal_offer_name = var.metrics_server_offer_name
113+
elastic_metal_subscription_period = var.subscription_period
114+
elastic_metal_server_name = var.metrics_server_name
115+
elastic_metal_hostname = var.metrics_server_hostname
116+
elastic_metal_description = var.metrics_server_description
117+
elastic_metal_ssh_key_name = var.metrics_server_ssh_key_name
118+
elastic_metal_ssh_public_key_path = var.ssh_public_key_path_scaleway
119+
elastic_metal_cloud_init_template_path = var.metrics_server_cloud_init_template_path
120+
elastic_metal_os_id = var.os_id
121+
elastic_metal_tailscale_key_expiry = var.tailscale_key_expiry
122+
elastic_metal_tailscale_tags = var.tailscale_tags
123+
elastic_metal_tags = var.metrics_server_tags
124+
}

0 commit comments

Comments
 (0)