Skip to content

stackit_network_area_region / stackit_network_area_route: stale state when the regional configuration or the network area is gone (400 on read, 404 in delete wait) #1751

Description

@devpie

Description

Follow-up to #1749 / #1750. Two more resources under a network area keep stale state entries when the network area or its regional configuration is deleted outside of Terraform, because they only treat HTTP 404 as "gone" and one of them fails before the delete call.

Observed on 2026-09-07 while reproducing #1749 (provider v0.114.0 and the build from #1750 behave the same here, the code paths are untouched by #1750):

  1. stackit_network_area_region.Read() fails on 400 {"code":400,"msg":"region not enabled"}, which the API answers for GET /v2/organizations/{org}/network-areas/{area}/regions/{region} when the regional configuration was deleted but the network area still exists. Read() only handles 404 (stackit/internal/services/iaas/networkarearegion/resource.go, Read), so every plan fails while the resource is in state.
  2. stackit_network_area_region.Delete() calls wait.ReadyForNetworkAreaDeletionWaitHandler before the delete call. With the network area gone, that wait fails with 404 resource not found: area and Delete() reports Error deleting network area region: Network area ready for deletion waiting: 404 Not Found. The 404 tolerance only covers the DeleteNetworkAreaRegion call itself. Hit with tofu destroy -refresh=false; with a refresh first, Read() removes the resource on the 404 and the problem does not show.
  3. By code inspection, not reproduced: stackit_network_area_route Read() and Delete() (stackit/internal/services/iaas/networkarearoute/resource.go) use the same 404-only check under the same /network-areas/{area}/regions/{region}/... path.

Steps to reproduce

resource "stackit_network_area" "area" {
  organization_id = var.organization_id
  name            = "example"
}

resource "stackit_network_area_region" "region" {
  organization_id = var.organization_id
  network_area_id = stackit_network_area.area.network_area_id
  ipv4 = {
    network_ranges   = [{ prefix = "10.61.0.0/16" }]
    transfer_network = "10.62.0.0/24"
  }
}
  1. terraform apply
  2. stackit network-area region delete --network-area-id <area> --region eu01 --organization-id <org> -y
  3. terraform plan → problem 1
  4. stackit network-area delete <area> --organization-id <org> -y, then terraform destroy -refresh=false → problem 2

Actual behavior

Error: Error reading network area region
Calling API: 400 Bad Request, status code 400, Body: {"code":400,"msg":"region not enabled"}
Error: Error deleting network area region
Network area ready for deletion waiting: 404 Not Found, status code 404, Body: {"code":404,"msg":"resource not found: area"}

Expected behavior

  • Read() removes the regional configuration from state when the API answers 404, or 400 for a missing regional configuration (the SDK's DeleteNetworkAreaRegionWaitHandler already treats both as deleted).
  • Delete() treats a 404 from the readiness wait as "network area already gone" and succeeds.
  • stackit_network_area_route handles the same cases.

Environment

  • OS: macOS 26.6.2 (arm64)
  • Terraform version: OpenTofu v1.12.6
  • Version of the STACKIT Terraform provider: v0.114.0

Additional information

relates to #1749

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions