Skip to content

add project moving ability - #140

Merged
bshutterkion merged 2 commits into
mainfrom
move-accounts
Jan 22, 2026
Merged

add project moving ability#140
bshutterkion merged 2 commits into
mainfrom
move-accounts

Conversation

@bshutterkion

Copy link
Copy Markdown
Collaborator

Add Project Move Between OUs Support

Summary

This PR adds the ability to move projects between OUs without destroying and recreating them. Previously, changing a project's ou_id would trigger a destroy/recreate cycle, which failed if the project had accounts attached ("Cannot delete a project with accounts attached" error).

Now, changing ou_id uses Kion's /v2/project/{id}/move API to relocate the project in-place, preserving attached accounts.

Changes

New Features

  • Project Move Support: Changing ou_id now moves the project instead of destroying/recreating it
  • move_ou_settings Block: Optional configuration to control move behavior:
    • cloud_rule_setting: "convert" (default) or "remove" - how inherited cloud rules are handled
    • financial_setting: "move" (default) or "preserve" - how financial history is handled

Bug Fixes

  • Fixed project_id not being included in the move API request body (caused 400 Bad Request)

Default Behavior

  • cloud_rule_setting defaults to "convert" (inherited cloud rules become local rules)
  • financial_setting defaults to "move" (financial history moves with project, project ID stays the same)

Note: Using financial_setting = "preserve" creates a NEW project in the destination OU with a new ID, which causes Terraform state drift. This is not recommended for Terraform-managed projects.

Example Usage

resource "kion_project" "example" {
  name                 = "My Project"
  ou_id                = 11  # Change this value to move the project
  permission_scheme_id = 1

  owner_user_group_ids {
    id = 1
  }

  # Optional: customize move behavior
  move_ou_settings {
    cloud_rule_setting = "convert"  # or "remove"
    financial_setting  = "move"     # or "preserve" (not recommended)
  }
}

Files Changed

  • kion/resource_project.go - Added move logic and move_ou_settings schema
  • kion/internal/kionclient/models_project.go - Added ProjectMoveCommand struct
  • examples/resources/kion_project/resource.tf - Added move example
  • docs/resources/project.md - Auto-generated from examples

Testing

Tested the following scenarios against a local Kion instance:

Test Configuration Result
Move with defaults (no move_ou_settings) Uses convert + move ✅ PASSED
Move with financial_setting = "move" Explicit setting ✅ PASSED
Move with cloud_rule_setting = "remove" Combined with move ✅ PASSED

All tests confirmed:

  • Project moves successfully between OUs
  • Project ID remains unchanged (with financial_setting = "move")
  • Attached accounts move with the project

@bshutterkion
bshutterkion requested a review from egramens January 22, 2026 20:28
@bshutterkion
bshutterkion merged commit f4fcb5c into main Jan 22, 2026
1 check passed
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