feat: Created post-install script
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
resource "hcloud_firewall" "this" {
|
||||
name = "prod-firewall"
|
||||
|
||||
rule { # server ssh
|
||||
rule { # server ssh - wired to the vpn server's public IP only, see infra/main.tf
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "22"
|
||||
@@ -88,6 +88,25 @@ resource "hcloud_server" "this" {
|
||||
network_id = var.network_id
|
||||
ip = var.private_ip
|
||||
}
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
host = self.ipv4_address
|
||||
user = "root"
|
||||
private_key = file(var.ssh_private_key_path)
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
content = var.bootstrap_script
|
||||
destination = "/root/bootstrap.sh"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"chmod +x /root/bootstrap.sh",
|
||||
"/root/bootstrap.sh",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
resource "hcloud_volume" "storage" {
|
||||
|
||||
@@ -34,7 +34,7 @@ variable "volume_size" {
|
||||
}
|
||||
|
||||
variable "allowed_ssh_source_ips" {
|
||||
description = "CIDRs allowed to reach port 22 on prod."
|
||||
description = "CIDRs allowed to reach port 22 on prod. Set by the root module to the vpn server's public IP."
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
@@ -42,3 +42,13 @@ variable "network_ip_range" {
|
||||
description = "CIDR of the private network, allowed through the firewall for traffic from dev."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "bootstrap_script" {
|
||||
description = "Rendered post-install script, uploaded and executed on the server immediately after creation."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ssh_private_key_path" {
|
||||
description = "Local path to the private key matching var.ssh_key_id, used to run the bootstrap script over SSH."
|
||||
type = string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user