From 33f9f4daf7fe2a0304724b320258fe2ef9b26bed Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 20 Jul 2026 18:33:39 -0700 Subject: [PATCH] terraform: fmt normalization + deprecated resource rename + commit lockfile Ran `terraform init && terraform validate && terraform fmt` after installing terraform 1.9.8 locally (which the initial commit couldn't do since terraform wasn't on the authoring host). Changes: - fmt: alignment normalization on image.tf, store_vm.tf, bmpgen_vm.tf, outputs.tf. - proxmox_virtual_environment_download_file -> proxmox_download_file (deprecated in bpg/proxmox v0.111.1, removed in v1.0). - .terraform.lock.hcl: unignored + committed. Pins bpg/proxmox to v0.111.1 and hashicorp/random to v3.9.0 so contributors get the same provider set on `terraform init`. `terraform validate` is now Success, no warnings. Co-Authored-By: Claude Opus 4.7 --- .gitignore | 6 ++--- terraform/.terraform.lock.hcl | 45 +++++++++++++++++++++++++++++++++++ terraform/bmpgen_vm.tf | 14 +++++------ terraform/image.tf | 16 ++++++------- terraform/outputs.tf | 6 ++--- terraform/store_vm.tf | 22 ++++++++--------- 6 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 terraform/.terraform.lock.hcl diff --git a/.gitignore b/.gitignore index c0a4897..9f3dd38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ -# Terraform state -- has infra addresses and (with older providers) can leak -# secrets if written unencrypted. Never commit. +# Terraform provider binaries + state. +# .terraform.lock.hcl (dependency lock file) IS committed per HashiCorp +# best practice -- it pins provider versions across contributors. terraform/.terraform/ -terraform/.terraform.lock.hcl terraform/*.tfstate terraform/*.tfstate.* terraform/*.tfstate.backup diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..1a10f11 --- /dev/null +++ b/terraform/.terraform.lock.hcl @@ -0,0 +1,45 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/bpg/proxmox" { + version = "0.111.1" + constraints = "~> 0.60" + hashes = [ + "h1:ML2D3UUZTM99yrll/EBXj7wBYMb8xmQgomqFNybEoxY=", + "zh:18fb7c31a08dde6bffa1a4d4a211e604d6d17eec7092fd59331b3db3c6f3742c", + "zh:1cd60761538289d4dd2a1086b3ae62a7b0bdd4b1a2f824e9a44e243413168dba", + "zh:2eb76f6fc8299b6820ff678c8252332cc3366e226b5ae2e61748fd2449c1ed92", + "zh:45e6f7ebd0bf48911d37060359a4f359b5743b3092e985295733990e406d0416", + "zh:4aa8ba912eae37975d2e983394d173e595ca34fc76b5bf220b37d0e99d76e98c", + "zh:58e0789923103a77d502a0a9fc3eb920625e8eb935ec2d4ac0d006aebd1d186c", + "zh:6df8aa85fb8865915537e946c19b02538ad188018a629759c213c6f03730f642", + "zh:6ed47bc00d0913a1d0880618fa1376115e9edab6b4a658c081061a7f0e4ca360", + "zh:c5b10ff4f33df7e4c29e8f1127d49845b561b37b57517e844fb0954d7923d65e", + "zh:d016510e14b738499f0db9d9b3aafe82fc6877fb4ab4e9f831fb68a8d70a1385", + "zh:d941f394069bbf24351b363da1c64383f487067aaee0a84f9b96476d4912e212", + "zh:ddf271dbc2632ae8ffa8de3972f243ee47d260cb2ac90aa784f2746d98e21a0f", + "zh:ed0caa3501c42f611b7e9622c9b1df69fd85dc25a3cd88d3076381829688cd62", + "zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.9.0" + constraints = "~> 3.6" + hashes = [ + "h1:UlBuNVuCGJ39tTv2c5gz2NRZnQbXfbIWbTzWcth5o74=", + "zh:161ad0bd9a75768c82f53fb6e7172a9d8be2d4889b012645a34795031aaf1bf1", + "zh:19dc9a5b17729725ccfc4f45b0500af0ee5bc6b6b160c7adb8f2bf617d2c80ea", + "zh:269eda8fe42daa7974d5a34d166c3ba9defe80cde86c01e4dadcfdf2e1f05e5f", + "zh:373f7c65566f8f2cc7f45d698654feb9d988996957e1266a69ca00c52d6d16d0", + "zh:5599d16804c41c83009ec621b6d6b6f74e102f5827678a4750f8809055546b61", + "zh:583be0440469a22bff70dcfa56593b01566860b29607437264adb51060cf46fc", + "zh:5f211d8ec3f2e1f414870d9584bfe26e6995560ef81c748f8447a48164767398", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:7b547fd16216761ef86efc3ed516ac5ac0c5c42b7c7eb24a08cef2d93f69ed5e", + "zh:7e7c0679daf2a382151d05068c8c3f0dae6b7b7dccf818827b73dd08638df2ef", + "zh:8089dec888a8038b9b4fb23b3df7e1057293dbc5b60b42cc47ff690d69d4b61b", + "zh:c51f15a031edfd6f23ce8ced3446ca7f8d8d647e2499890d7d5d10d5016d7257", + "zh:c94784f005708890dc6895afd53636ec00ec1e430b15d41e5aebfb1d4b39bd04", + ] +} diff --git a/terraform/bmpgen_vm.tf b/terraform/bmpgen_vm.tf index 4ccb731..d1f8f38 100644 --- a/terraform/bmpgen_vm.tf +++ b/terraform/bmpgen_vm.tf @@ -17,12 +17,12 @@ locals { bmpgen_store_addr = var.store_vm_ip_cidr != "" ? split("/", var.store_vm_ip_cidr)[0] : "" bmpgen_user_data = templatefile("${path.module}/cloud-init/bmpgen.cloud-init.yaml.tftpl", { - hostname = local.bmpgen_hostname - ssh_username = var.ssh_username - ssh_public_key = trimspace(file(var.ssh_public_key_path)) - store_ip_addr = local.bmpgen_store_addr - router_facing_port = var.router_facing_port - local_asn = var.test_local_asn + hostname = local.bmpgen_hostname + ssh_username = var.ssh_username + ssh_public_key = trimspace(file(var.ssh_public_key_path)) + store_ip_addr = local.bmpgen_store_addr + router_facing_port = var.router_facing_port + local_asn = var.test_local_asn }) } @@ -55,7 +55,7 @@ resource "proxmox_virtual_environment_vm" "bmpgen" { disk { datastore_id = var.vm_storage_pool - file_id = proxmox_virtual_environment_download_file.ubuntu_noble.id + file_id = proxmox_download_file.ubuntu_noble.id interface = "scsi0" size = 16 ssd = true diff --git a/terraform/image.tf b/terraform/image.tf index 4b1c8ad..a3a0b98 100644 --- a/terraform/image.tf +++ b/terraform/image.tf @@ -1,15 +1,15 @@ # One-time Ubuntu cloud image download. bpg/proxmox handles the "did I # already download this?" check by URL + storage; safe to re-run. -resource "proxmox_virtual_environment_download_file" "ubuntu_noble" { +resource "proxmox_download_file" "ubuntu_noble" { content_type = "iso" datastore_id = var.image_storage node_name = var.pve_node - url = var.ubuntu_image_url - file_name = "noble-server-cloudimg-amd64.img" - checksum = var.ubuntu_image_checksum != "" ? var.ubuntu_image_checksum : null - checksum_algorithm = var.ubuntu_image_checksum != "" ? "sha256" : null - overwrite = false - overwrite_unmanaged = false - upload_timeout = 900 + url = var.ubuntu_image_url + file_name = "noble-server-cloudimg-amd64.img" + checksum = var.ubuntu_image_checksum != "" ? var.ubuntu_image_checksum : null + checksum_algorithm = var.ubuntu_image_checksum != "" ? "sha256" : null + overwrite = false + overwrite_unmanaged = false + upload_timeout = 900 } diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 9a0093a..635ec3c 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -5,7 +5,7 @@ output "store_vm_ip" { description = "IPv4 the store VM will be reachable on." value = var.store_vm_ip_cidr != "" ? split("/", var.store_vm_ip_cidr)[0] : ( length(proxmox_virtual_environment_vm.store.ipv4_addresses) > 1 ? - proxmox_virtual_environment_vm.store.ipv4_addresses[1][0] : "" + proxmox_virtual_environment_vm.store.ipv4_addresses[1][0] : "" ) } @@ -13,7 +13,7 @@ output "bmpgen_vm_ip" { description = "IPv4 the bmpgen VM will be reachable on." value = var.bmpgen_vm_ip_cidr != "" ? split("/", var.bmpgen_vm_ip_cidr)[0] : ( length(proxmox_virtual_environment_vm.bmpgen.ipv4_addresses) > 1 ? - proxmox_virtual_environment_vm.bmpgen.ipv4_addresses[1][0] : "" + proxmox_virtual_environment_vm.bmpgen.ipv4_addresses[1][0] : "" ) } @@ -31,7 +31,7 @@ output "grafana_url" { output "next_steps" { description = "What to do after apply." - value = <<-EOT + value = <<-EOT Cloud-init on both VMs runs for ~5-10 minutes after apply completes. Poll the store VM until it's up, then run the assertions: diff --git a/terraform/store_vm.tf b/terraform/store_vm.tf index 8cd8f0f..dcd1b51 100644 --- a/terraform/store_vm.tf +++ b/terraform/store_vm.tf @@ -15,13 +15,13 @@ locals { store_ip_addr = var.store_vm_ip_cidr != "" ? split("/", var.store_vm_ip_cidr)[0] : "" store_user_data = templatefile("${path.module}/cloud-init/store.cloud-init.yaml.tftpl", { - hostname = local.store_hostname - ssh_username = var.ssh_username - ssh_public_key = trimspace(file(var.ssh_public_key_path)) - obmp_repo_url = var.obmp_repo_url - obmp_repo_ref = var.obmp_repo_ref - router_facing_port = var.router_facing_port - static_ip_addr = local.store_ip_addr + hostname = local.store_hostname + ssh_username = var.ssh_username + ssh_public_key = trimspace(file(var.ssh_public_key_path)) + obmp_repo_url = var.obmp_repo_url + obmp_repo_ref = var.obmp_repo_ref + router_facing_port = var.router_facing_port + static_ip_addr = local.store_ip_addr }) } @@ -54,7 +54,7 @@ resource "proxmox_virtual_environment_vm" "store" { disk { datastore_id = var.vm_storage_pool - file_id = proxmox_virtual_environment_download_file.ubuntu_noble.id + file_id = proxmox_download_file.ubuntu_noble.id interface = "scsi0" size = var.vm_disk_gb ssd = true @@ -62,9 +62,9 @@ resource "proxmox_virtual_environment_vm" "store" { } network_device { - bridge = var.vm_bridge - model = "virtio" - vlan_id = var.vm_vlan_tag != 0 ? var.vm_vlan_tag : null + bridge = var.vm_bridge + model = "virtio" + vlan_id = var.vm_vlan_tag != 0 ? var.vm_vlan_tag : null } operating_system { type = "l26" }