Skip to content

fix(iaas): remove UseStateForUnknown in network_interface and volume resource - #1770

Merged
marceljk merged 1 commit into
mainfrom
fix/iaas-unexpected-new-value-in-volume-and-nic
Sep 16, 2026
Merged

marceljk merged 1 commit into
mainfrom
fix/iaas-unexpected-new-value-in-volume-and-nic

Conversation

@marceljk

@marceljk marceljk commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Description

relates to SSD3RD-11683

Testing instructions

  1. Verify first the existing issue. Checkout the main branch and run $ make build
  2. Use the following Terraform config and run it with $ terraform apply -var="env_stage=v1"
# ==============================================================================
# TERRAFORM CONFIGURATION
# ==============================================================================
terraform {
  required_providers {
    stackit = {
      source = "stackitcloud/stackit"
    }
    tls = {
      source  = "hashicorp/tls"
      version = ">= 4.0.0"
    }
  }
}


provider "stackit" {
  default_region = "eu01"
}


# ==============================================================================
# TERMINAL CONTROL VARIABLE
# ==============================================================================
variable "env_stage" {
  type        = string
  description = "Version tag that triggers the change scenario (e.g., v1, v2)"
  default     = "v1"
}


variable "project_id" {
  type    = string
  default = "" # TODO set to your project ID
}


variable "image_id" {
  type    = string
  default = "d333affd-9f00-446d-978f-524cb0384360"
}


# ==============================================================================
# DYNAMIC CONFIGURATION MAP (All Changes Are Managed Here)
# ==============================================================================
locals {
  # All names change dynamically based on the "env_stage" parameter provided from the terminal:
  cfg = {
    # --- RENAME & RECREATE GROUP ---
    server_name          = "jumphost-server-${var.env_stage}"
    keypair_name         = "jumphost-keypair-${var.env_stage}"
    update_schedule_name = "update-schedule-${var.env_stage}"


    # --- MODIFICATIONS ONLY GROUP ---
    sg_description   = "Jumphost SG Description ${var.env_stage}"
    volume_label_env = "poc-${var.env_stage}"
  }
}


# ==============================================================================
# REPRODUCED RESOURCES
# ==============================================================================


# 1. Modifications Only: Security Group
resource "stackit_security_group" "jumphost_sg" {
  project_id  = var.project_id
  name        = "vedat-poc-25152.jumphost-sg"
  description = local.cfg.sg_description # Modification Trigger
}


# 2. Network & Modifications Only: Network Interface
resource "stackit_network" "this" {
  project_id       = var.project_id
  name             = "vedat-poc-25152.poc-network"
  ipv4_nameservers = ["1.1.1.1"]
  ipv4_prefix      = "192.168.10.0/24"
  routed           = true
}


resource "stackit_network_interface" "this" {
  count              = 1
  project_id         = var.project_id
  network_id         = stackit_network.this.network_id
  security_group_ids = [stackit_security_group.jumphost_sg.security_group_id]

  labels = {
    environment = local.cfg.volume_label_env # Modification Trigger (Label Change)
    managed_by  = "terraform"
  }
}

# 3. Rename/Recreate: Key Pair
resource "tls_private_key" "generated_key" {
  algorithm = "RSA"
  rsa_bits  = 2048
}


resource "stackit_key_pair" "jumphost_keypair" {
  name       = local.cfg.keypair_name # Rename Trigger
  public_key = chomp(tls_private_key.generated_key.public_key_openssh)
}


# 4. Modifications Only: Volumes (Boot & Persistent)
resource "stackit_volume" "boot" {
  count             = 1
  project_id        = var.project_id
  name              = "vedat-poc-25152.boot-volume"
  size              = 20
  availability_zone = "eu01-1"


  labels = {
    environment = local.cfg.volume_label_env # Modification Trigger (Label Change)
    managed_by  = "terraform"
  }


  source = {
    type = "image"
    id   = var.image_id
  }
}


resource "stackit_volume" "jumphost_persistent_volume" {
  project_id        = var.project_id
  name              = "vedat-poc-25152.persistent-volume"
  size              = 10
  availability_zone = "eu01-1"


  labels = {
    environment = local.cfg.volume_label_env # Modification Trigger (Label Change)
    type        = "persistent"
  }
}


# 5. Rename/Recreate: Target Server
resource "stackit_server" "this" {
  project_id        = var.project_id
  name              = local.cfg.server_name # Rename Trigger
  machine_type      = "c2i.1"
  availability_zone = "eu01-1"
  keypair_name      = stackit_key_pair.jumphost_keypair.name


  boot_volume = {
    source_type = "volume"
    source_id   = stackit_volume.boot[0].volume_id
  }


  network_interfaces = [
    stackit_network_interface.this[0].network_interface_id
  ]
}


# 6. Rename/Recreate: Volume Attachment
resource "stackit_server_volume_attach" "jumphost_persistent_volume_attachment" {
  project_id = var.project_id
  server_id  = stackit_server.this.server_id
  volume_id  = stackit_volume.jumphost_persistent_volume.volume_id
}
  1. After the apply run it again but set v2 for env_stage: $ terraform apply -var="env_stage=v2"
  2. The apply will stop with 3 errors. All of them say that the provider produces inconsistent result after apply.
  3. Run again $ terraform apply -var="env_stage=v2", to finish the open updates
  4. Checkout this PR and run $ make build
  5. Run now again an apply but set v3 for env_stage: $ terraform apply -var="env_stage=v3"
  6. This time the apply should be successful on the first run.
  7. Run $ terraform destroy to clean up the resources

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@marceljk
marceljk requested a review from a team as a code owner September 16, 2026 11:35
@marceljk
marceljk force-pushed the fix/iaas-unexpected-new-value-in-volume-and-nic branch from 580695a to ccb69be Compare September 16, 2026 11:36
@marceljk
marceljk merged commit fc2a33c into main Sep 16, 2026
3 checks passed
@marceljk
marceljk deleted the fix/iaas-unexpected-new-value-in-volume-and-nic branch September 16, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants