Skip to Content
Open Beta — managed Kubernetes, DNS & more are live.
🏗️

Automate with the Patrii Terraform provider

Updated 2026-11-20
On this page

Automate with the Patrii Terraform provider

The Patrii Terraform provider describes your networks, instances, volumes, DNS, load balancers and more as code, so you can review, repeat and version your infrastructure.

Declare the provider, give it an application credential through environment variables, and run terraform plan and terraform apply as usual. Each service guide in this documentation shows the matching resources next to the console and CLI steps.

The provider reads PATRII_APPLICATION_CREDENTIAL_ID and PATRII_APPLICATION_CREDENTIAL_SECRET. The Patrii CLI uses shorter names, PATRII_APP_CREDENTIAL_ID and PATRII_APP_CREDENTIAL_SECRET; set both pairs if one pipeline runs both tools.

Before you start

  • Terraform installed on your computer or in your pipeline.
  • An application credential for the target project, created from Application credentials in your account or the project's actions menu.

Step by step

  1. Declare the provider

    Add the required_providers block and a provider "patrii" block to your configuration.

  2. Provide the credential

    Export the application credential ID and secret. Optional variables PATRII_PROJECT_ID, PATRII_PROJECT_NAME, PATRII_REGION and PATRII_AUTH_URL match the provider attributes of the same name.

  3. Plan and apply

    Run terraform init, review terraform plan, then terraform apply.

Examples

Provider configuration
terraform {
  required_providers {
    patrii = {
      source = "PatriiCloud/patrii"
    }
  }
}

provider "patrii" {
  auth_url = "https://api.patrii.cloud"
  # region, project_id and the credential come from the environment
}
Credentials from the environment
export PATRII_APPLICATION_CREDENTIAL_ID=<credential-id>
export PATRII_APPLICATION_CREDENTIAL_SECRET=<credential-secret>
export PATRII_PROJECT_ID=<project-id>      # optional: the credential is project-scoped
export PATRII_REGION=<region>              # optional
terraform init
terraform plan

Limits & specifications

Provider settings:

AttributeEnvironment variable
auth_urlPATRII_AUTH_URL
application_credential_idPATRII_APPLICATION_CREDENTIAL_ID
application_credential_secretPATRII_APPLICATION_CREDENTIAL_SECRET
project_idPATRII_PROJECT_ID
project_namePATRII_PROJECT_NAME
regionPATRII_REGION

Best practices

  • Keep the credential secret out of your .tf files and state outputs; pass it through the environment or your pipeline's secret store.
  • Use one application credential per pipeline so you can revoke one without breaking the others.

Learn more

Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.

Was this article helpful?
Thank you for your feedback. Still stuck? Contact us