Uses reserved ip address.

main
Thomas Hintz 3 weeks ago
parent e50cd410f1
commit fd9ee57a0b

@ -15,4 +15,4 @@ storage:
set -euo pipefail
# This script demonstrates how templating and variable substitution works when using Terraform templates for Container Linux Configs.
hostname="$(hostname)"
echo My name is ${name} and the hostname is $${hostname} and this is updated!
echo My name is ${name} and the hostname is $${hostname} and this is updated, again 4x!

@ -70,6 +70,12 @@ resource "digitalocean_custom_image" "flatcar" {
regions = [var.datacenter]
}
resource "digitalocean_reserved_ip" "machine" {
for_each = toset(var.machines)
# droplet_id = digitalocean_droplet.machine[each.key].id
region = digitalocean_droplet.machine[each.key].region
}
resource "digitalocean_droplet" "machine" {
for_each = toset(var.machines)
name = "${var.cluster_name}-${each.key}"
@ -83,6 +89,12 @@ resource "digitalocean_droplet" "machine" {
}
}
resource "digitalocean_reserved_ip_assignment" "machine" {
for_each = toset(var.machines)
ip_address = digitalocean_reserved_ip.machine[each.key].ip_address
droplet_id = digitalocean_droplet.machine[each.key].id
}
data "ct_config" "machine-ignitions" {
for_each = toset(var.machines)
content = templatefile("${path.module}/cl/machine-${each.key}.yaml.tmpl", {
@ -98,3 +110,10 @@ output "ip-addresses" {
"${var.cluster_name}-${key}" => digitalocean_droplet.machine[key].ipv4_address
}
}
output "reserved-ip-addresses" {
value = {
for key in var.machines :
"${var.cluster_name}-${key}" => digitalocean_reserved_ip.machine[key].ip_address
}
}

Loading…
Cancel
Save