Permit.io is a cloud-based authorization service that allows you to define and manage permissions for your application. In order to make it easier and safer to manage your objects and policies in Permit.io, we have created a Terraform provider.
This provider repository is built on the Terraform Plugin Framework. The template repository built on the Terraform Plugin SDK can be found at terraform-provider-scaffolding. See Which SDK Should I Use? in the Terraform documentation for additional information.
The examples directory contains a number of examples of how to use the provider.
terraform {
required_providers {
permitio = {
source = "registry.terraform.io/permitio/permit-io"
version = "~> 0.0.1"
}
}
}
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
}
resource "permitio_resource" "document" {
key = "document"
name = "Document"
description = "A confidential document"
actions = {
"read" : {
"name" : "Read",
"description" : "Read a document",
},
"write" : {
"name" : "Write",
"description" : "Write a document",
}
}
attributes = {}
}
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)
]
}
resource "permitio_user_attribute" "department" {
key = "department"
description = "The department of the user"
type = "string"
}
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
go install
This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
Fill this in for each provider
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
To generate or update documentation, run go generate
.
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
make testacc