Skip to content

Commit

Permalink
facilitate upgrade from null_resource to terraform_data
Browse files Browse the repository at this point in the history
  • Loading branch information
janfrederik committed Nov 15, 2024
1 parent 5a09f6c commit 8db5fe3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 1 deletion.
16 changes: 16 additions & 0 deletions agents.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ locals {
) }
}

moved {
from = null_resource.agent_config
to = terraform_data.agent_config
}
resource "terraform_data" "agent_config" {
for_each = local.agent_nodes

Expand Down Expand Up @@ -86,6 +90,10 @@ resource "terraform_data" "agent_config" {
}
}

moved {
from = null_resource.agents
to = terraform_data.agents
}
resource "terraform_data" "agents" {
for_each = local.agent_nodes

Expand Down Expand Up @@ -145,6 +153,10 @@ resource "hcloud_volume" "longhorn_volume" {
delete_protection = var.enable_delete_protection.volume
}

moved {
from = null_resource.configure_longhorn_volume
to = terraform_data.configure_longhorn_volume
}
resource "terraform_data" "configure_longhorn_volume" {
for_each = { for k, v in local.agent_nodes : k => v if((v.longhorn_volume_size >= 10) && (v.longhorn_volume_size <= 10240) && var.enable_longhorn) }

Expand Down Expand Up @@ -195,6 +207,10 @@ resource "hcloud_floating_ip_assignment" "agents" {
]
}

moved {
from = null_resource.configure_floating_ip
to = terraform_data.configure_floating_ip
}
resource "terraform_data" "configure_floating_ip" {
for_each = { for k, v in local.agent_nodes : k => v if coalesce(lookup(v, "floating_ip"), false) }

Expand Down
8 changes: 8 additions & 0 deletions autoscaler-agents.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ locals {
}
}

moved {
from = null_resource.configure_autoscaler
to = terraform_data.configure_autoscaler
}
resource "terraform_data" "configure_autoscaler" {
count = length(var.autoscaler_nodepools) > 0 ? 1 : 0

Expand Down Expand Up @@ -155,6 +159,10 @@ data "hcloud_servers" "autoscaled_nodes" {
with_selector = "hcloud/node-group=${local.cluster_prefix}${each.value}"
}

moved {
from = null_resource.autoscaled_nodes_registries
to = terraform_data.autoscaled_nodes_registries
}
resource "terraform_data" "autoscaled_nodes_registries" {
for_each = local.autoscaled_nodes
triggers_replace = {
Expand Down
12 changes: 12 additions & 0 deletions control_planes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ locals {
) }
}

moved {
from = null_resource.control_plane_config
to = terraform_data.control_plane_config
}
resource "terraform_data" "control_plane_config" {
for_each = local.control_plane_nodes

Expand Down Expand Up @@ -155,6 +159,10 @@ resource "terraform_data" "control_plane_config" {
}


moved {
from = null_resource.authentication_config
to = terraform_data.authentication_config
}
resource "terraform_data" "authentication_config" {
for_each = local.control_plane_nodes

Expand Down Expand Up @@ -186,6 +194,10 @@ resource "terraform_data" "authentication_config" {
]
}

moved {
from = null_resource.control_planes
to = terraform_data.control_planes
}
resource "terraform_data" "control_planes" {
for_each = local.control_plane_nodes

Expand Down
8 changes: 8 additions & 0 deletions init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ resource "hcloud_load_balancer" "cluster" {
}


moved {
from = null_resource.first_control_plane
to = terraform_data.first_control_plane
}
resource "terraform_data" "first_control_plane" {
connection {
user = "root"
Expand Down Expand Up @@ -111,6 +115,10 @@ resource "random_password" "rancher_bootstrap" {
}

# This is where all the setup of Kubernetes components happen
moved {
from = null_resource.kustomization
to = terraform_data.kustomization
}
resource "terraform_data" "kustomization" {
triggers_replace = {
# Redeploy helm charts when the underlying values change
Expand Down
8 changes: 8 additions & 0 deletions kustomization_user.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ locals {
user_kustomization_templates = try(fileset("extra-manifests", "**/*.yaml.tpl"), toset([]))
}

moved {
from = null_resource.kustomization_user
to = terraform_data.kustomization_user
}
resource "terraform_data" "kustomization_user" {
for_each = local.user_kustomization_templates

Expand Down Expand Up @@ -33,6 +37,10 @@ resource "terraform_data" "kustomization_user" {
]
}

moved {
from = null_resource.kustomization_user_deploy
to = terraform_data.kustomization_user_deploy
}
resource "terraform_data" "kustomization_user_deploy" {
count = length(local.user_kustomization_templates) > 0 ? 1 : 0

Expand Down
8 changes: 8 additions & 0 deletions modules/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ resource "hcloud_server" "server" {

}

moved {
from = null_resource.registries
to = terraform_data.registries
}
resource "terraform_data" "registries" {
triggers_replace = {
registries = var.k3s_registries
Expand Down Expand Up @@ -154,6 +158,10 @@ data "cloudinit_config" "config" {
}
}

moved {
from = null_resource.zram
to = terraform_data.zram
}
resource "terraform_data" "zram" {
triggers_replace = {
zram_size = var.zram_size
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.5.0"
required_version = ">= 1.9.0"
required_providers {
github = {
source = "integrations/github"
Expand Down

0 comments on commit 8db5fe3

Please sign in to comment.