<@U08614ZV82F> please describe policy migration fr...
# permit-saas
g
@Ask Inkeep please describe policy migration from development to staging and finally production
a
Thanks for tagging me @Graham. I'll look through relevant sources and get back to you shortly.
p
Hey, thanks for reaching out ! It seems our team is a little busy right now, a human will be with you within the next hour or so. In the meantime, can I help you ?
a
Policy migration in Permit.io follows a structured CI/CD workflow using environments that correspond to your development stages. Here's how to migrate policies from development to staging and finally to production: CI/CD Flow Overview Every CI flow starts with a source environment, which is copied to a staging or preview environment, tested, reviewed, approved, then merged into the target environment (1) . The process uses the Environment API to manage these transitions . Two Main Approaches 1. Staging Flow This approach uses one staging environment where you apply and test policy changes before merging to production . The process is: • Copy from development to staging using the
copy-env
API • Test and review changes in staging • Once approved, copy from staging to production 2. Preview Branches Flow (Recommended) This creates dynamic environments for each policy "pull request" : • Use the
create-env
API to create a preview environment • Use the
copy-env
API to copy from source to the preview environment • After testing, use
copy-env
again to merge into production Using the CLI for Migration The Permit CLI provides commands to manage this workflow (2) :
Copy code
permit env create --api-key permit_key --name "Staging" --description "Staging environment for testing"
To promote policies between environments:
Copy code
permit env copy --api-key permit_key --from staging --to production
GitOps Integration You can map branches when connecting your Permit Project to a repository (1) . This creates two lines of branches: • Your application branches • Your policy branches (Permit Environments) These are connected through PDPs using environment API-secret-keys to sync to specific environments . Environment Access Control Each environment can have its own access control to gate who can affect the policy at each stage . For example, you can give only the developer who triggered the CI flow access to the preview environment . Key Points to Remember • PDPs are deployed with environment-specific API keys • You can migrate an application to a new policy by simply pointing its PDP to a new environment • The system maintains version control and consistency across environments using a Git-like model
To learn more, see the sources I considered: [[1] Manage Policy Life Cycle - CI/CD](https://docs.permit.io/how-to/SDLC/CI-CD) [[2] Introducing the New Permit.io CLI: A New Era of Access Control Developer Experience](https://www.permit.io/blog/introducing-the-new-permit-cli)
e
Hey @Graham Just wanted to check in, did the AI response answer your question about policy migration? Let me know if you need any further clarification or help, happy to assist!
g
@Eli Moshkovich There are gaps in my understanding. Are policies like migrating database changes?
o
Hey @Graham, policy migration from dev->staging->production can be done using one of two approaches • Using the copy env API ( see docs ref here, here and api ref here ) • Using terraform to manage permit policies then deploying changes from dev->staging->production can be done using native terraform apply command and managed via branches or any other gitops preferred way I personally prefer the terraform approach as a “gitops native” approach but both approaches are valid and used by different customers
g
@Omer Zuarets Terraform looks like the way to go. I already use git and github. My production is hosted at the Digitalocean App platform [haven’t launched a live service yet]. Is Terraform compatible?
o
Terraform is just a tool to write IaC using HCL The tool itself doesn’t really “care” where you store the code or run the CI/CD
👍 1
g
@Ask Inkeep Does Terraform link with Digitial Ocean Application platform?
a
Thanks for tagging me @Graham. I'll look through relevant sources and get back to you shortly.
Yes, Terraform can work with DigitalOcean App Platform. The Permit.io Terraform Provider manages your authorization policies as infrastructure-as-code (1) (2) , while DigitalOcean has its own Terraform provider for managing your app deployment infrastructure. Here's how they work together: ​*Permit.io Terraform Provider Configuration:*​
Copy code
terraform {  
 required_providers {  
 permitio = {  
 source = "<http://registry.terraform.io/permitio/permit-io|registry.terraform.io/permitio/permit-io>"  
 version = "~> 0.0.1"  
 }  
 }  
}
(1)
Copy code
provider "permitio" {  
 api_url = "<https://api.permit.io>" # Defaults to - "<https://api.permit.io> - Can be set as an environment variable PERMITIO_API_URL  
 api_key = "YOUR_API_KEY" # Can be set as an environment variable PERMITIO_API_KEY  
}
The Permit Terraform Provider decouples policy configuration from data, allowing you to define roles, permissions, and resources using Terraform's declarative syntax (2) . You can version your policies, manage branches, and integrate them seamlessly with your CI/CD pipeline . For your DigitalOcean App Platform deployment, you'd use DigitalOcean's Terraform provider alongside Permit's provider. Your Terraform configuration would manage both: • DigitalOcean infrastructure (via DO's provider) • Permit.io authorization policies (via Permit's provider) Consider using the Permit Terraform provider to manage environment baselines and policy changes systematically (3) . Since policies are now part of your infrastructure as code, you can version them, manage branches, and integrate them seamlessly with your CI/CD pipeline (2) .
To learn more, see the sources I considered: [[1] 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] Permit.io Best Practices](https://docs.permit.io/overview/best-practices)
g
@Ask Inkeep Tell me about DigitalOceans terraform provider
a
Thanks for tagging me @Graham. I'll look through relevant sources and get back to you shortly.
I don't have information about DigitalOcean's Terraform provider in the available Permit.io documentation. What I can tell you is how the Permit.io Terraform Provider works, which you can use alongside DigitalOcean's provider in your infrastructure setup (1) (2) . The Permit.io Terraform Provider allows you to manage your authorization policies as infrastructure-as-code . Here's the configuration:
Copy code
terraform {  
 required_providers {  
 permitio = {  
 source = "<http://registry.terraform.io/permitio/permit-io|registry.terraform.io/permitio/permit-io>"  
 version = "~> 0.0.1"  
 }  
 }  
}
(1)
Copy code
provider "permitio" {  
 api_url = "<https://api.permit.io>" # Defaults to - "<https://api.permit.io> - Can be set as an environment variable PERMITIO_API_URL  
 api_key = "YOUR_API_KEY" # Can be set as an environment variable PERMITIO_API_KEY  
}
With Permit's Terraform Provider, you can create resources like roles and permissions :
Copy code
resource "permitio_role" "reader" {  
 key = "reader"  
 name = "Reader"  
 description = "A role that allows reading documents"  
 permissions = [  
 "document:read"  
 ]  
 extends = []  
 depends_on = [  
permitio_resource.document # This is required to ensure that the resource is created before the role (for the permissions assignment)  
 ]  
}
The Permit Terraform Provider decouples policy configuration from data, allowing you to define roles, permissions, and resources using Terraform's declarative syntax (2) . Since policies are now part of your infrastructure as code, you can version them, manage branches, and integrate them seamlessly with your CI/CD pipeline . For specific information about DigitalOcean's Terraform provider and how to configure it with thei
To learn more, see the sources I considered: [[1] 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)