From b6513aa86e71530b7eebaf6450e455ba8f9f2a19 Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 23 Dec 2025 20:09:06 +0100 Subject: [PATCH] fix: update Terraform workflow to download and upload state files --- .github/workflows/terraform.yaml | 17 ++- terraform/terraform.tfstate | 208 ----------------------------- terraform/terraform.tfstate.backup | 208 ----------------------------- 3 files changed, 16 insertions(+), 417 deletions(-) delete mode 100644 terraform/terraform.tfstate delete mode 100644 terraform/terraform.tfstate.backup diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml index 744d292..ca41f32 100644 --- a/.github/workflows/terraform.yaml +++ b/.github/workflows/terraform.yaml @@ -6,7 +6,7 @@ on: jobs: terraform: - runs-on: ssot + runs-on: ubuntu-latest container: image: hashicorp/terraform:1.6.6 @@ -23,6 +23,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + # Download previous Terraform state if it exists + - name: Download previous Terraform state + uses: actions/download-artifact@v3 + with: + name: terraform-state + path: terraform/ + continue-on-error: true # skip if no previous state exists + - name: Terraform Init run: terraform -chdir=terraform init -input=false @@ -46,3 +54,10 @@ jobs: - name: Terraform Apply if: github.ref == 'refs/heads/main' run: terraform -chdir=terraform apply -input=false -auto-approve tfplan + + # Upload updated Terraform state + - name: Upload Terraform state + uses: actions/upload-artifact@v3 + with: + name: terraform-state + path: terraform/terraform.tfstate diff --git a/terraform/terraform.tfstate b/terraform/terraform.tfstate deleted file mode 100644 index 0189ab3..0000000 --- a/terraform/terraform.tfstate +++ /dev/null @@ -1,208 +0,0 @@ -{ - "version": 4, - "terraform_version": "1.14.3", - "serial": 16, - "lineage": "2f42bf18-041f-78d9-24cc-d9a193bc3daf", - "outputs": {}, - "resources": [ - { - "mode": "managed", - "type": "hcloud_firewall", - "name": "production_fw", - "provider": "provider[\"registry.terraform.io/hetznercloud/hcloud\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "apply_to": [], - "id": "10323541", - "labels": {}, - "name": "production-fw", - "rule": [ - { - "description": "", - "destination_ips": [ - "0.0.0.0/0", - "::/0" - ], - "direction": "out", - "port": "any", - "protocol": "tcp", - "source_ips": [] - }, - { - "description": "", - "destination_ips": [ - "0.0.0.0/0", - "::/0" - ], - "direction": "out", - "port": "any", - "protocol": "udp", - "source_ips": [] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "22", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "443", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "80", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - } - ] - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "hcloud_network", - "name": "prodnet", - "provider": "provider[\"registry.terraform.io/hetznercloud/hcloud\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "delete_protection": false, - "expose_routes_to_vswitch": false, - "id": "11773043", - "ip_range": "10.0.0.0/16", - "labels": {}, - "name": "prod-network" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster", - "name": "hetzner_cluster", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "cluster_group_id": 1, - "cluster_type_id": 1, - "comments": "", - "description": "", - "id": "1", - "location_id": 0, - "name": "Hetzner Cluster", - "region_id": 0, - "site_group_id": 0, - "site_id": 0, - "tags": [], - "tags_all": [], - "tenant_id": 0 - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==", - "dependencies": [ - "netbox_cluster_group.hetzner", - "netbox_cluster_type.openstack" - ] - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster_group", - "name": "hetzner", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "description": "Hetzner Cloud Hosts", - "id": "1", - "name": "hetzner", - "slug": "hetzner" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster_type", - "name": "openstack", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "id": "1", - "name": "Openstack", - "slug": "openstack" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_ip_range", - "name": "prodnet", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "description": null, - "end_address": "10.0.255.254/16", - "id": "1", - "role_id": null, - "size": 65534, - "start_address": "10.0.0.1/16", - "status": "active", - "tags": [], - "tags_all": [], - "tenant_id": null, - "vrf_id": null - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - } - ], - "check_results": null -} diff --git a/terraform/terraform.tfstate.backup b/terraform/terraform.tfstate.backup deleted file mode 100644 index 085d5dc..0000000 --- a/terraform/terraform.tfstate.backup +++ /dev/null @@ -1,208 +0,0 @@ -{ - "version": 4, - "terraform_version": "1.14.3", - "serial": 14, - "lineage": "2f42bf18-041f-78d9-24cc-d9a193bc3daf", - "outputs": {}, - "resources": [ - { - "mode": "managed", - "type": "hcloud_firewall", - "name": "production_fw", - "provider": "provider[\"registry.terraform.io/hetznercloud/hcloud\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "apply_to": [], - "id": "10323541", - "labels": {}, - "name": "production-fw", - "rule": [ - { - "description": "", - "destination_ips": [ - "0.0.0.0/0", - "::/0" - ], - "direction": "out", - "port": "any", - "protocol": "tcp", - "source_ips": [] - }, - { - "description": "", - "destination_ips": [ - "0.0.0.0/0", - "::/0" - ], - "direction": "out", - "port": "any", - "protocol": "udp", - "source_ips": [] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "22", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "443", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - }, - { - "description": "", - "destination_ips": [], - "direction": "in", - "port": "80", - "protocol": "tcp", - "source_ips": [ - "0.0.0.0/0", - "::/0" - ] - } - ] - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "hcloud_network", - "name": "prodnet", - "provider": "provider[\"registry.terraform.io/hetznercloud/hcloud\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "delete_protection": false, - "expose_routes_to_vswitch": false, - "id": "11773043", - "ip_range": "10.0.0.0/16", - "labels": {}, - "name": "prod-network" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster", - "name": "hetzner_cluster", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "cluster_group_id": 1, - "cluster_type_id": 1, - "comments": "", - "description": "", - "id": "1", - "location_id": 0, - "name": "hetzner_openstack_cluster", - "region_id": 0, - "site_group_id": 0, - "site_id": 0, - "tags": null, - "tags_all": [], - "tenant_id": 0 - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==", - "dependencies": [ - "netbox_cluster_group.hetzner", - "netbox_cluster_type.openstack" - ] - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster_group", - "name": "hetzner", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "description": "Hetzner Cloud Hosts", - "id": "1", - "name": "hetzner", - "slug": "hetzner" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_cluster_type", - "name": "openstack", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "id": "1", - "name": "Openstack", - "slug": "openstack" - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - }, - { - "mode": "managed", - "type": "netbox_ip_range", - "name": "prodnet", - "provider": "provider[\"registry.terraform.io/e-breuninger/netbox\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "description": null, - "end_address": "10.0.255.254/16", - "id": "1", - "role_id": null, - "size": 65534, - "start_address": "10.0.0.1/16", - "status": "active", - "tags": [], - "tags_all": [], - "tenant_id": null, - "vrf_id": null - }, - "sensitive_attributes": [], - "identity_schema_version": 0, - "private": "bnVsbA==" - } - ] - } - ], - "check_results": null -}