Manage Kestra Governance Policies with the Terraform Provider
For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append.mdto anykestra.io/docs/*URL for plain Markdown.
Terraform Resource: kestra_policy
Manages a Kestra governance Policy (EE) at the INSTANCE, TENANT or NAMESPACE scope. A policy bundles mutate and validate rules applied to flows and plugins; its YAML source is persisted by the API and round-tripped verbatim. STATIC policies are declared in the Kestra configuration and cannot be managed through the API.
Example usage
# A tenant-scope policy narrowed to a namespace subtreeresource "kestra_policy" "tenant" { scope = "TENANT" policy_id = "deny-shell-commands"
content = <<EOTid: deny-shell-commandsdisplayName: Deny shell commandsdescription: Disallow the shell Commands plugin on the data teamsenforcement: ACTIVEtarget: namespaces: - company.teamrules: - type: io.kestra.plugin.ee.rules.Deny on: PLUGIN action: BLOCK errorMessage: Shell commands are not allowed where: - field: type operator: EQUAL_TO value: io.kestra.plugin.scripts.shell.CommandsEOT}
# A namespace-scope policy requiring an owner label on every flowresource "kestra_policy" "namespace" { scope = "NAMESPACE" policy_id = "require-owner-label" namespace = "company.team"
content = <<EOTid: require-owner-labelrules: - type: io.kestra.plugin.ee.rules.Require on: FLOW properties: - labels.owner errorMessage: Flows must carry an owner labelEOT}
# An instance-scope policy (super-admin only), narrowed to some tenantsresource "kestra_policy" "instance" { scope = "INSTANCE" policy_id = "inject-http-timeout"
content = <<EOTid: inject-http-timeouttarget: tenants: - productionrules: - type: io.kestra.plugin.ee.rules.Add on: PLUGIN where: - field: type operator: EQUAL_TO value: io.kestra.plugin.core.http.Request values: options: readTimeout: PT30SEOT}Schema
Required
content(String) The policy YAML source:id, optionaldisplayName,description,enforcement(defaults toACTIVE) andtarget, and the non-emptyruleslist mixing mutate rules (io.kestra.plugin.ee.rules.Add,Delete) and validate rules (Deny,Require,Restrict). The scope, tenant and namespace are carried by the resource attributes, never by the content. Diffs are compared semantically, so a change that only reindents, reorders keys or edits comments produces no plan and the source persisted by the API keeps its previous formatting; change a value to push a reformatted source.policy_id(String) The policy id — a lowercase RFC 1123 label, unique per (scope, tenant, namespace). Must match theidof the YAML content.scope(String) The policy scope:INSTANCE(deployment-wide, super-admin only),TENANTorNAMESPACE.
Optional
namespace(String) The namespace the policy is attached to. Required for theNAMESPACEscope, must not be set otherwise.tenant_id(String) The tenant id, forTENANTandNAMESPACEscopes. Defaults to the provider tenant when omitted; the value is captured at create time, so changing the provider tenant later does not retarget existing policies. Must not be set for theINSTANCEscope.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import kestra_policy.instance INSTANCE/{{policy_id}}terraform import kestra_policy.tenant TENANT/{{tenant_id}}/{{policy_id}}terraform import kestra_policy.namespace NAMESPACE/{{tenant_id}}/{{namespace}}/{{policy_id}}Was this page helpful?