Also, is there a way to promote changes to policie...
# permit-saas
b
Also, is there a way to promote changes to policies through environments, so that I dont have to recreate them in each?
a
Hi @Bradley Herrup, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Yes, you can promote policy changes through environments without recreating them manually. Permit.io provides environment copying and merging capabilities specifically for this purpose. (1) Copying/Merging Environments (EAP) Environments can be copied into new environments or merged into existing environments to manage policy changes in a controlled manner. This is useful when you want to test adding new Resources, Roles, or Condition Sets. For example, you can copy your production environment to development, make changes, test them, then merge back to production. Via API You can copy an environment using the API:
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"
    }
  }
}'
For large environments, use the Background API for asynchronous copying:
Copy code
curl --location '<https://api.permit.io/v2/projects/default/envs/staging/copy/async>' \
-H 'authorization: Bearer API_SECRET_KEY' \
--data '{
  "target_env": {
    "new": {
      "key": "prod",
      "name": "production"
    }
  }
}'
What Gets Copied Only Policy objects are copied/merged, including: • Resources (with actions, attributes, roles, relations) • Roles (with permissions, derivations, hierarchy) • Condition Sets (with user sets, resource sets, rules, inheritance) • Custom Policies Directory objects like Users, Tenants, and Resource Instances are not copied. CI/CD Integration The
copy-env
API can be used to merge/promote changes between environments as part of your CI/CD pipeline, maintaining consistency and efficiency. (2) GitOps Alternative With GitOps enabled, environments are branches in your policy repository. (3) This allows you to manage policy changes through standard Git workflows - merging branches effectively promotes policies between environments.
To learn more, see the sources I considered: [[1] Create a new Environment](https://docs.permit.io/manage-your-account/creating-environments) [[2] Permit.io Best Practices](https://docs.permit.io/overview/best-practices) [[3] GitOps Overview](https://docs.permit.io/integrations/gitops/overview)
o
Another option which the AI missed, and my personal favorite is via managing the policies with Terraform, easily re apply a policy on multiple envs @Ask Inkeep please add docs link
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
You're absolutely right! The Permit.io Terraform Provider is an excellent way to manage and promote policies across multiple environments. (1) With Terraform, you can define your authorization policies as infrastructure-as-code and easily apply them across different environments. (2) The Terraform Provider allows you to manage roles, permissions, and resources using Terraform's declarative syntax, then simply run
terraform apply
to deploy your policies. Here's the documentation link for the Terraform Provider: Permit.io Terraform Provider (1) You can also use the Permit CLI to export your existing environment configuration as Terraform HCL files: (3)
Copy code
permit env export terraform --file <http://permit-config.tf|permit-config.tf>
This makes it easy to start with Terraform even if you've already configured policies through the UI - you can export your current setup and then manage it as code going forward. (7)
To learn more, see the sources I considered: [[1] Permit.io Terraform Provider](https://docs.permit.io/integrations/infra-as-code/terraform-provider) [[2] Permit.io Launch Week - Day 3: Fine-Grained Modeling](https://www.permit.io/blog/launch-week-3-fine-grained-modeling) [[3] Environments management using the Permit CLI](https://docs.permit.io/how-to/permit-cli/permit-cli-envs)