Skip to content

Execution order when moving projects to a different folder and deleting the old folder #1659

Description

@HartmannVolker

Description

I tried to move projects from one folder to another and then delete the old folder afterwards (because it was empty). When running everything in one apply terraform will first try to delete the old folder and fail, because it's not empty.

Steps to reproduce

  1. Create a Folder with at least one project in it
resource "stackit_resourcemanager_folder" "folder_1" {
  name                = "folder_1"
  owner_email         = "foo.bar@stackit.cloud"
  parent_container_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

resource "stackit_resourcemanager_folder" "folder_2" {
  name                = "folder_2"
  owner_email         = "foo.bar@stackit.cloud"
  parent_container_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

resource "stackit_resourcemanager_project" "example_project" {
  name                = "example-project"
  owner_email         = "foo.bar@stackit.cloud"
  parent_container_id = stackit_resourcemanager_folder.folder_1.container_id
}
  1. Move the project to a different folder and delete the old folder at the same time.
resource "stackit_resourcemanager_folder" "folder_2" {
  name                = "folder_2"
  owner_email         = "foo.bar@stackit.cloud"
  parent_container_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

resource "stackit_resourcemanager_project" "example_project" {
  name                = "example-project"
  owner_email         = "foo.bar@stackit.cloud"
  parent_container_id = stackit_resourcemanager_folder.folder_2.container_id
}
  1. Run terraform apply:
  │ {"timeStamp":"2026-08-04T14:55:02.907949687Z","path":"/resource-management/v2/folders/folder_1"status":409,"error":"Conflict","message":"[FOLDER]
  │ has children of type project. Forced deletion not permitted for
  │ containerId[xxxxxxx]"}

Actual behavior

Terraform tries to delete the folder first before moving the project within to the new folder

Expected behavior

I would expect terraform to figure out the correct execution order and move projects first before attempting to delete the old folder.

Environment

  • Terraform version (see terraform --version): v1.13.5
  • Version of the STACKIT Terraform provider: 0.106.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions