From 2d192b6c8c6d5ac491a19048e0089ec0cba31fff Mon Sep 17 00:00:00 2001
From: Sven-Hendrik Haase <svenstaro@gmail.com>
Date: Sun, 31 Mar 2019 04:15:45 +0200
Subject: [PATCH] Move terraform script to root to have terraform find it
 automatically

---
 terraform/archlinux.tf => archlinux.tf | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
 rename terraform/archlinux.tf => archlinux.tf (60%)

diff --git a/terraform/archlinux.tf b/archlinux.tf
similarity index 60%
rename from terraform/archlinux.tf
rename to archlinux.tf
index d5ca3ede3..a98e3f836 100644
--- a/terraform/archlinux.tf
+++ b/archlinux.tf
@@ -2,7 +2,9 @@ terraform {
   backend "pg" {}
 }
 
-variable "hetzner_cloud_api_key" {}
+data "external" "hetzner_cloud_api_key" {
+  program = ["bash", "${path.module}/misc/get_hetzner_cloud_api_key_terraform.sh"]
+}
 
 # Find the id using `hcloud image list`
 variable "archlinux_image_id" {
@@ -10,17 +12,12 @@ variable "archlinux_image_id" {
 }
 
 provider "hcloud" {
-  token = "${var.hetzner_cloud_api_key}"
-}
-
-resource "hcloud_floating_ip" "bbs" {
-  type = "ipv4"
-  server_id = "${hcloud_server.bbs.id}"
+  token = "${data.external.hetzner_cloud_api_key.result.hetzner_cloud_api_key}"
 }
 
 resource "hcloud_rdns" "bbs" {
-  floating_ip_id = "${hcloud_floating_ip.bbs.id}"
-  ip_address = "${hcloud_floating_ip.bbs.ip_address}"
+  server_id = "${hcloud_server.bbs.id}"
+  ip_address = "${hcloud_server.bbs.ipv4_address}"
   dns_ptr = "bbs.archlinux.org"
 }
 
-- 
GitLab