Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tf/environments/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ module "ooni_clickhouse_proxy" {

key_name = module.adm_iam_roles.oonidevops_key_name
instance_type = "t3a.nano"
# 512 MiB without swap: unattended-upgrades OOMed it (OOPRIV-140)
swap_size_mb = 1024

name = "oonickprx"
ingress_rules = [{
Expand Down
2 changes: 1 addition & 1 deletion tf/modules/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ data "cloudinit_config" "ooni_ec2" {
part {
filename = "init.cfg"
content_type = "text/cloud-config"
content = templatefile("${path.module}/templates/cloud-init.yml", {})
content = templatefile("${path.module}/templates/cloud-init.yml", { swap_size_mb = var.swap_size_mb })
}

}
Expand Down
12 changes: 12 additions & 0 deletions tf/modules/ec2/templates/cloud-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%{ if swap_size_mb > 0 ~}
swap:
filename: /swapfile
size: ${swap_size_mb * 1048576}
write_files:
- path: /etc/sysctl.d/99-swappiness.conf
content: |
vm.swappiness=10
# systemd-sysctl ran before cloud-init wrote the file
runcmd:
- [sysctl, -p, /etc/sysctl.d/99-swappiness.conf]
%{ endif ~}
8 changes: 7 additions & 1 deletion tf/modules/ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ variable "iam_instance_profile_name" {
description = "Optional IAM instance profile name for the instance (e.g. YACE via IMDS)"
default = null
type = string
}
}

variable "swap_size_mb" {
description = "Size of a swapfile created by cloud-init at first boot, in MiB. 0 means no swap. Only new instances get it: user_data changes are ignored on existing ones"
default = 0
type = number
}
Loading