Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace null_resource with terraform_data #69

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

160 changes: 69 additions & 91 deletions example/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions k3s_registry/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ variable "server" {
})
}

resource "null_resource" "k3s_registry" {
triggers = {
resource "terraform_data" "k3s_registry" {
triggers_replace = {
id = var.server.id
}

Expand Down
12 changes: 6 additions & 6 deletions main-setup.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ module "registry_control" {
private_key = tls_private_key.ssh.private_key_openssh
}

resource "null_resource" "k3sup_control" {
resource "terraform_data" "k3sup_control" {
depends_on = [module.registry_control]

triggers = {
triggers_replace = {
id = hcloud_server.control.id
ip = hcloud_server_network.control.ip
}
Expand Down Expand Up @@ -64,18 +64,18 @@ module "registry_worker" {
private_key = tls_private_key.ssh.private_key_openssh
}

resource "null_resource" "k3sup_worker" {
resource "terraform_data" "k3sup_worker" {
count = var.worker_count

depends_on = [module.registry_worker]

triggers = {
triggers_replace = {
id = hcloud_server.worker[count.index].id
ip = hcloud_server_network.worker[count.index].ip

# Wait the control-plane to be initialized, and re-join the new cluster if the
# control-plane server changed.
control_id = null_resource.k3sup_control.id
control_id = terraform_data.k3sup_control.id
}

connection {
Expand Down Expand Up @@ -105,7 +105,7 @@ resource "null_resource" "k3sup_worker" {
# Configure kubernetes

data "local_sensitive_file" "kubeconfig" {
depends_on = [null_resource.k3sup_control]
depends_on = [terraform_data.k3sup_control]
filename = local.kubeconfig_path
}

Expand Down
4 changes: 0 additions & 4 deletions providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ terraform {
source = "hashicorp/local"
version = ">= 2.5.1, < 3.0.0"
}
null = {
source = "hashicorp/null"
version = ">= 3.2.2, < 4.0.0"
}
tls = {
source = "hashicorp/tls"
version = ">= 4.0.5, < 5.0.0"
Expand Down
Loading