Add OU/Project import support to importer script + fix api_call 401 retry - #148
Merged
Merged
Conversation
Adds import_ous() and import_projects() so the importer emits kion_ou and kion_project resources, not just their Cloud Access Roles. Wires in --skip-ous / --skip-projects flags. OUs import fully where owners are assigned locally; the root OU is skipped (no valid parent). Projects are best-effort: the Kion API does not return permission_scheme_id (placeholder + TODO) and only exposes locally-assigned owners via the permission mapping, so inherited-owner resources are flagged with TODO comments rather than fabricated. Also fixes the provider version pin in templates.py from the non-existent 0.13.12 to the latest published 0.3.34, which unblocks terraform init on generated output.
On a 401 the retry call's result was never returned, so the function fell through to 'return False' even when the retry succeeded. Callers then saw False and reported empty results (e.g. '0 roles'/'0 projects') on any endpoint that hit a transient 401. Return the retried call (forwarding the original method/payload/headers) so its data propagates to the caller.
egramens
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to import Kion OUs and Projects themselves (as
kion_ou/kion_projectresources) to the importer script, and fixes a retry bug inapi_callthat could cause resources to import as empty.Previously the importer only imported the Cloud Access Roles attached to OUs/Projects, not the OUs/Projects as manageable Terraform resources.
Changes
import_ous.py(new) — imports OUs askion_ouresources. The root OU (no valid parent) is skipped. OUs with locally-assigned owners import cleanly and validate against the provider schema.import_projects.py(new) — imports Projects askion_projectresources (best-effort, see limitations below).--skip-ous/--skip-projectsflags added; wired intomain().api_call401-retry fix — on a 401 the retry result was never returned, so the function fell through toreturn Falseeven when the retry succeeded. Callers then sawFalseand reported empty results (e.g. "0 roles"/"0 projects") on any endpoint that hit a transient 401. The retry now returns its result, forwarding the original method/payload/headers.templates.py— corrected the generatedprovider.tfversion pin from the non-existent0.13.12to the current published0.3.34, which unblocksterraform initon generated output.Known limitations (documented in README)
These stem from the Kion API not returning fields that the
kion_ou/kion_projectresources require on read — not from the importer:permission_scheme_idis not returned by any API endpoint, so a placeholder is written with a# TODO. Owners are inferred from the project's permission mapping (Admin app role) where present; otherwise a# TODOis written. Budgets/funding are not imported.# TODO(the resource requires at least one owner).In both cases the importer flags the gap rather than fabricating values, so generated files for affected resources will not
plancleanly until theTODOs are resolved.Testing
terraform fmt).terraform init+terraform validateagainst the real provider schema: OUs with local owners validate 100% clean; the only validation errors are the documented owner-requirement gaps.