Introduction
Introduction Statistics Contact Development Disclaimer Help
Adding checks to Terraform. - infra - Terraform IoC for my remote (Hetzner) and…
Log
Files
Refs
README
---
commit 6059ade6222248d2522642bd2ef33e38371635ac
parent 6e1286b5e3433c0dc66e2e643de7bdadb23e4486
Author: Jay Scott <[email protected]>
Date: Fri, 30 Jun 2023 17:21:45 +0100
Adding checks to Terraform.
Diffstat:
A terraform/checks.tf | 8 ++++++++
R terraform/id_rsa.pub -> terraform/… | 0
M terraform/main.tf | 7 +++++++
M terraform/terraform.tfvars | 2 +-
4 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/terraform/checks.tf b/terraform/checks.tf
@@ -0,0 +1,8 @@
+check "server_status" {
+ assert {
+ condition = alltrue([
+ for k, v in var.nodes : hcloud_server.this[k].status == "running"
+ ])
+ error_message = "Server status check failed."
+ }
+}
diff --git a/terraform/id_rsa.pub b/terraform/files/id_rsa.pub
diff --git a/terraform/main.tf b/terraform/main.tf
@@ -52,6 +52,13 @@ resource "hcloud_server" "this" {
ipv4_enabled = each.value.ipv4
ipv6_enabled = each.value.ipv6
}
+
+ lifecycle {
+ postcondition {
+ condition = self.status == "running"
+ error_message = "Instance must be running."
+ }
+ }
}
resource "hcloud_rdns" "this" {
diff --git a/terraform/terraform.tfvars b/terraform/terraform.tfvars
@@ -1,5 +1,5 @@
public_ssh_keys = {
- main = "./id_rsa.pub"
+ main = "./files/id_rsa.pub"
}
firewall_rules = {
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.