Hey, is it possible to export a manifest/schema fi...
# general
m
Hey, is it possible to export a manifest/schema file with the ReBAC definition I created in the UI to Permit? And vice versa, is it possible to create this definition via a file and then import it into the UI?
o
Yes you can do so via Terraform and our CLI utility @Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
Yes, you can export and import ReBAC definitions using the Permit CLI's Terraform export functionality. Exporting ReBAC Schema You can export your Permit environment configuration (including ReBAC definitions) as a Terraform HCL file using (1) :
Copy code
permit env export terraform --file permit-config.tf
This command exports all environment content including resources, roles, user sets, resource sets, and condition sets in the Permit Terraform provider format . You can also print the output to console without saving to a file :
Copy code
permit env export terraform
Importing via Terraform Once exported, you can use the generated Terraform configuration to recreate your ReBAC schema in other environments. The Terraform Provider allows you to manage policy schemas as code and integrate policy management directly into your software development lifecycle (2) . Alternative: Template-Based Setup You can also use policy templates for common ReBAC patterns (3) :
Copy code
permit env template list
Copy code
permit env template apply --template <template-name>
​*Note:*​ There's currently an open GitHub issue regarding incomplete policy rule exports in Terraform (4) , but the core schema elements (resources, roles, relationships) should export correctly.
To learn more, see the sources I considered: [[1] Environments management using the Permit CLI](https://docs.permit.io/how-to/permit-cli/permit-cli-envs) [[2] Permit.io Launch Week - Day 3: Fine-Grained Modeling](https://www.permit.io/blog/launch-week-3-fine-grained-modeling) [[3] Policy - AI, Templates, OpenAPI](https://docs.permit.io/how-to/permit-cli/permit-cli-policy) [[4] Bug: Missing Policy Rules in Terraform Export](https://github.com/permitio/permit-cli/issues/130)
Thanks for the feedback, glad I was helpful.