Hi, Is there a possibility to clone a development ...
# permit-saas
y
Hi, Is there a possibility to clone a development environment into a other(production) environment? So all roles and resources are exactly the same as in the development environement?
a
Hi @Yorrick Elzinga, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Yes, you can clone/copy environments in Permit.io, including from development to production (1) . This feature allows you to duplicate all policy objects (roles, resources, etc.) from one environment to another . Copying Environments via API You can copy an environment into a new environment or merge into an existing one :
Copy code
curl --location '<https://api.permit.io/v2/projects/{project_id}/envs/{env_id}/copy>' \
  -H 'authorization: Bearer API_SECRET_KEY' \
  --data '{
    "target_env": {
      "new": {
        "key": "prod",
        "name": "production"
      }
    }'
Using the CLI The Permit CLI provides a simpler way to copy environments (2) :
Copy code
$ permit env copy --api-key permit_key --from staging --to production --conflict-strategy overwrite
What Gets Copied When copying environments, the following policy objects are copied (1) : • Resources (including actions, attributes, roles, and relations) • Roles (including permissions, derivations, and hierarchy) • Condition Sets (including user sets, resource sets, rules, and inheritance) • Custom Policies (if using GitOps) Note: Directory objects like Users, Tenants, and Resource Instances are NOT copied . Handling Conflicts When merging into an existing environment, you can choose conflict resolution strategies : • ​*Fail*​ (default) : Rollback the entire merge if conflicts arise • ​*Overwrite*​: Replace existing objects with those from the source environment This feature is particularly useful for managing changes to your policy in a controlled manner, allowing you to test changes in development before merging them to production .
To learn more, see the sources I considered: [[1] Create a new Environment](https://docs.permit.io/manage-your-account/creating-environments) [[2] Environments management using the Permit CLI](https://docs.permit.io/how-to/permit-cli/permit-cli-envs)
y
how to use permit cli?
a
Note that Directory objects like Users, Tenants, and Resource Instances are NOT copied .
Just making sure you saw it. In case you want to transfer the directory - first, retrieve your data through the API or the PDP cache; then, create a script to move it to the target environment.
how to use permit cli?
Have a look at our docs - here
y
Thnx, is it possible to copy elements aswell?
I managed to copy the roles etc
a
@Ask Inkeep
a
Thanks for tagging me @Alon Boshi. I'll look through relevant sources and get back to you shortly.
When copying environments, Permit Elements are not automatically copied along with the policy objects (1) . The environment copy feature only copies Policy objects such as Resources, Roles, and Condition Sets . Directory objects (Users, Tenants, Resource Instances) are explicitly not copied . The documentation doesn't specifically mention Permit Elements in the context of environment copying. Since Elements are UI components that embed user management, access requests, and approval flows into your application (2) , they would need to be configured separately in each environment. If you need to replicate your Elements configuration in the new environment, you would need to set them up again through the Permit UI or configure them programmatically, as shown in the Mesa Verde example where Elements are configured in a
setup.js
file .
To learn more, see the sources I considered: [[1] Create a new Environment](https://docs.permit.io/manage-your-account/creating-environments) [[2] Fintech / Banking Demo Application](https://docs.permit.io/modeling/mesa-verde)
Thanks for the feedback, glad I was helpful.
y
Ok thnx
💜 1