How-To: Automate EZCA Certificates with Terraform Using the Keytos Terraform Provider

Learn how to authenticate the Keytos Terraform Provider with Entra ID, give it access to your EZCA domains, and deploy and auto-renew private PKI certificates as code.

Overview - How to Manage Your Private PKI Certificates as Code with Terraform

The Keytos Terraform Provider lets you request, renew, and revoke EZCA SSL/TLS certificates from your Terraform configurations, so your certificates live in the same code, reviews, and pipelines as the rest of your infrastructure. This guide walks you through how the provider signs in to EZCA, how to give it access to your domains, and a full deployment sample that renews your certificates automatically from a scheduled GitHub Actions pipeline.

🌐 Keytos Terraform Provider

What Can You Manage with the Keytos Terraform Provider?

Type Name What it does
Data source keytos_ezca_ssl_authority Looks up one of your CAs and its SSL template, and confirms that Terraform’s identity can reach it. Returns the CA’s key type and hash algorithm.
Resource keytos_ezca_ssl_leaf_cert Sends a certificate signing request (CSR) to your CA and stores the issued certificate. It renews the certificate during its early renewal period and revokes it when you destroy or replace it.

The provider never sees your private key. You generate the key and CSR with the HashiCorp TLS provider, and only the CSR is sent to EZCA.

Prerequisites for Using the Keytos Terraform Provider

  1. You have an active EZCA plan.
  2. You have a CA with an SSL template, such as an Issuing CA.
  3. You have Terraform 1.3 or later and the Azure CLI installed.
  4. You can register domains on that CA in the EZCA portal, or you can ask a Domain Owner to add Terraform’s identity to an existing domain.
  5. (for pipelines) You can create app registrations in Microsoft Entra ID.

How Does the Keytos Terraform Provider Authenticate to EZCA?

The Keytos Terraform Provider uses Microsoft Entra ID for authentication. It signs in with a Microsoft Entra ID identity, just like the EZCA portal does. When Terraform starts, the provider uses the Azure SDK’s DefaultAzureCredential to get an Entra ID access token and sends it with every request to EZCA. EZCA then checks that identity’s domain permissions before it issues or revokes a certificate.

That means two things must be in place before Terraform can issue a certificate:

  • Authentication: Terraform requires an Entra ID token sourced from az login, a service principal, or a managed identity.
  • Authorization: The Entra ID identity you’re signed into will need access to every domain included in the certificate in EZCA. You set this up in Step 2.

The EZCA Terraform provider will try these credentials in order and uses the first one that works:

Order Credential How it is configured Best for
1 Environment variables AZURE_TENANT_ID and AZURE_CLIENT_ID, plus AZURE_CLIENT_CERTIFICATE_PATH or AZURE_CLIENT_SECRET A service principal in any CI/CD system or HCP Terraform workspace
2 Workload identity AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_FEDERATED_TOKEN_FILE, set for you by the AKS workload identity webhook Terraform running in an Azure Kubernetes Service (AKS) pod
3 Managed identity An identity assigned to the Azure resource. Set AZURE_CLIENT_ID to pick a user-assigned identity. Azure VMs, self-hosted runners, and build agents running in Azure
4 Azure CLI Whoever is signed in with az login Your workstation, and pipelines that sign in with an Azure login step, such as GitHub Actions
5 Azure Developer CLI Whoever is signed in with azd auth login Workstations that use azd
6 Azure PowerShell Whoever is signed in with Connect-AzAccount Workstations that use Azure PowerShell

The token Terraform gets is a standard Azure Resource Manager token, but it is only used to prove who Terraform is. Your Terraform identity doesn’t need an Azure subscription or any Azure role assignments to use EZCA.

Step-by-Step Guide - How to Set Up the Keytos Terraform Provider and Deploy Certificates

The following steps will guide you through creating an identity for Terraform, giving it access in EZCA, signing in, and deploying a complete Terraform project that issues and renews your certificates.

Step 1: How to Choose and Create the Identity Terraform Uses to Sign In

Pick the identity based on where Terraform runs. We recommend a dedicated identity for each pipeline or environment, so you can give it access to only the domains it manages, and your EZCA audit logs show exactly what Terraform did.

Where Terraform runs Recommended identity Credential the provider uses
Your workstation, for testing Your own Entra ID user account Azure CLI (az login)
GitHub Actions An app registration with a federated credential (OIDC), so there is no secret to store or rotate Azure CLI, after the azure/login step
An Azure VM, self-hosted runner, or build agent in Azure A managed identity Managed identity
Any other CI/CD system, or HCP Terraform An app registration with a certificate Environment variables

We recommend avoiding client secrets whenever you can. Federated credentials and managed identities have no secret that can leak, and a certificate is much harder to steal than a secret copied into a pipeline variable.

If you are testing from your workstation, or Terraform runs with a managed identity, you can skip to Step 2. For a managed identity, write down its name, because you will search for it in EZCA.

How to Create an App Registration for Terraform

Run the following Azure CLI commands to create an app registration and its service principal. Replace terraform-ezca-production with a name that tells your team which pipeline uses it.

az login

APP_ID=$(az ad app create --display-name "terraform-ezca-production" --query appId -o tsv)
az ad sp create --id "$APP_ID"

# Save these values. You will use them in the next steps.
echo "Client ID: $APP_ID"
az account show --query tenantId -o tsv

You don’t need to add any API permissions to the app registration. EZCA only checks the identity in the token.

Next, give the app registration a credential. Select the tab for where Terraform runs:

A federated credential lets your GitHub Actions workflow sign in to Entra ID with a short-lived OIDC token, so there is no secret to store in GitHub.

  1. Create a file named credential.json. Replace contoso/ezca-certificates with your GitHub organization and repository. The subject must match the environment your workflow job uses. The GitHub Actions workflow in this guide uses production.

    {
      "name": "github-ezca-certificates-production",
      "issuer": "https://token.actions.githubusercontent.com",
      "subject": "repo:contoso/ezca-certificates:environment:production",
      "audiences": ["api://AzureADTokenExchange"]
    }
    
  2. Add the federated credential to your app registration:

    az ad app federated-credential create --id "$APP_ID" --parameters credential.json
    

A certificate credential works with any system that can store a file securely and set environment variables.

  1. Create a self-signed certificate and add it to your app registration. The command creates a PEM file that contains the certificate and private key, and prints its path:

    az ad app credential reset --id "$APP_ID" --create-cert --append --display-name "terraform-ezca"
    
  2. Store the PEM file in your CI/CD system’s secret store. It contains a private key, so never commit it to your repository.

Want EZCA to manage this credential too? You can upload a certificate issued by EZCA with az ad app credential reset --id "$APP_ID" --cert "@terraform-ezca.pem" --append, and EZCA can rotate Entra ID application certificates automatically.

Step 2: How to Give Terraform Access to Your Domains in EZCA

EZCA only issues SSL certificates for registered domains, and only to the identities each domain allows. Applications can’t be Domain Owners, so a person registers the domain and then adds Terraform’s identity to it.

We recommend adding Terraform’s identity as a Domain Certificate Administrator, which can request and revoke certificates for the domain. The provider revokes a certificate every time you destroy or replace it, so it needs both permissions. A Domain Requester can only request certificates.

Add the identity to every domain that appears in your certificate, including the common name and every subject alternative name (SAN).

How to Register a New Domain for Terraform

Follow these steps to register the domain. Select the CA you will use with Terraform as the Issuing CA, and under Domain Certificate Administrators, add your Terraform identity: your app registration’s display name, the name of your managed identity, or your own account if you are testing from your workstation.

  1. Go to your EZCA portal, such as https://portal.ezca.io.

  2. From the left-hand menu, navigate to My Domains.

  3. Click Register Domain.

    EZCA Cloud PKI My Domains page listing registered domains with Register Domain button highlighted
  4. From the Issuing CA dropdown, select the CA that will issue certificates for this domain.

    EZCA Cloud PKI Register New Domain form with Issuing CA dropdown highlighted showing Internal SSL Certs selected
  5. In the Domain field, enter the domain name or IP address you want to register, such as app.example.com. If your SSL CA has wildcard domain ownership turned on, you can instead enter a zone, such as *.dev.example.com, to own every name under it.

    EZCA Cloud PKI Register New Domain form with Domain field highlighted and filled in as 'app.example.com'
  6. Under Domain Owners, search for and add the users or groups who are responsible for this domain. Domain Owners can change the domain and manage who can request certificates for it, but they can’t request certificates themselves unless you also add them in one of the next two fields. Applications can’t be Domain Owners.

    EZCA Cloud PKI Register New Domain form with Domain Owners field highlighted and the PKI Admins group added
  7. Under Domain Certificate Administrators, search for and add the users, groups, or service principals that can request and revoke certificates for this domain. You must add at least one.

    EZCA Cloud PKI Register New Domain form with Domain Certificate Administrators field highlighted and a service principal added
  8. (optional) Under Domain Requesters, add the users, groups, or service principals that can request certificates for this domain but can’t revoke them.

  9. Click Register Domain.

    EZCA Cloud PKI Register New Domain form with Register Domain button highlighted to complete domain registration

How to Add Terraform to a Domain That Is Already Registered

  1. Go to your EZCA portal.

  2. From the left-hand menu, navigate to My Domains.

  3. Click View Details on the domain.

    EZCA Cloud PKI My Domains page listing registered domains with View Details button highlighted for a domain
  4. Under Domain Certificate Administrators, search for your Terraform identity by name and select it.

    EZCA Cloud PKI domain details page with Domain Certificate Administrators section highlighted showing a service principal added
  5. Click Save Domain Changes.

    EZCA Cloud PKI domain details page with Save Domain Changes button highlighted

To learn more about domain roles, see our guide on how to register a domain in EZCA.

Step 3: How to Find Your CA ID and Template ID in EZCA

Terraform needs two IDs to know which CA and template to request certificates from.

  1. Go to your EZCA portal.

  2. From the left-hand menu, navigate to Certificate Authorities.

  3. Find the CA you will use with Terraform and click View Requirements.

    EZCA Cloud PKI My CAs list showing multiple certificate authorities with View Requirements button highlighted for an SSL CA
  4. Under SSL Template Details > CA Details, copy the CAID and the Template ID. You will use them as authority_id and template_id in Terraform.

    EZCA Cloud PKI SSL Template Details page with CAID and Template ID fields highlighted in CA Details
  5. Under Certificate Lifetime, write down the Maximum Certificate Validity Period. The validity_period you set in Terraform can’t be longer than this.

    EZCA Cloud PKI SSL Template Details page with Maximum Certificate Validity Period field highlighted under Certificate Lifetime

Step 4: How to Sign In to EZCA from Terraform

Select the tab that matches where Terraform runs. Each one signs in with the identity you prepared in Step 1.

Sign in with the Azure CLI. Terraform uses your session automatically.

az login --tenant <your-tenant-id>

If your account doesn’t have access to any Azure subscriptions, add --allow-no-subscriptions. EZCA doesn’t need one.

(optional) Pin the provider to the Azure CLI so it doesn’t try other credentials first:

export AZURE_TOKEN_CREDENTIALS=AzureCLICredential
$env:AZURE_TOKEN_CREDENTIALS = "AzureCLICredential"

GitHub Actions doesn’t pass its OIDC token to the provider directly. Instead, the azure/login action signs in to the Azure CLI with your federated credential, and the provider then uses that Azure CLI session.

permissions:
  id-token: write # lets the job request an OIDC token from GitHub
  contents: read

jobs:
  terraform:
    runs-on: ubuntu-latest
    environment: production # must match the subject of your federated credential
    env:
      AZURE_TOKEN_CREDENTIALS: AzureCLICredential
    steps:
      - uses: azure/login@v3
        with:
          client-id: ${{ vars.AZURE_CLIENT_ID }}
          tenant-id: ${{ vars.AZURE_TENANT_ID }}
          allow-no-subscriptions: true

You can find the complete workflow in Step 7.

Run Terraform on an Azure resource that has a managed identity, such as a VM used as a self-hosted runner.

  • System-assigned identity: no configuration is needed.
  • User-assigned identity: set AZURE_CLIENT_ID to the identity’s client ID so the provider picks the right one.
export AZURE_CLIENT_ID="<user-assigned-identity-client-id>" # only for user-assigned identities
export AZURE_TOKEN_CREDENTIALS=ManagedIdentityCredential

Set these environment variables in the shell or pipeline that runs Terraform. In HCP Terraform, add them as Environment variables in your workspace and mark them as sensitive.

export AZURE_TENANT_ID="<your-tenant-id>"
export AZURE_CLIENT_ID="<app-registration-client-id>"
export AZURE_CLIENT_CERTIFICATE_PATH="/secure/path/terraform-ezca.pem"
export AZURE_TOKEN_CREDENTIALS=EnvironmentCredential
  • The certificate file can be PEM or PFX, and it must include the private key. If the PFX file has a password, also set AZURE_CLIENT_CERTIFICATE_PASSWORD.
  • If you must use a client secret, set AZURE_CLIENT_SECRET instead of AZURE_CLIENT_CERTIFICATE_PATH.

Step 5: How to Create Your Terraform Configuration with a Full Deployment Sample

This sample is a complete Terraform project that issues one or more certificates from your CA, keeps them renewed, and stores its state in Azure Storage so a pipeline can run it on a schedule. Create a folder with the following files:

ezca-certificates/
├── .github/
│   └── workflows/
│       └── ezca-certificates.yml
├── .gitignore
├── backend.tf
├── main.tf
├── outputs.tf
├── terraform.tfvars
├── variables.tf
└── versions.tf

versions.tf

Pins Terraform and the providers, and points the Keytos provider at your EZCA instance.

terraform {
  required_version = ">= 1.3"

  required_providers {
    keytos = {
      source  = "markeytos/keytos"
      version = "~> 0.1"
    }
    tls = {
      source  = "hashicorp/tls"
      version = "~> 4.0"
    }
  }
}

# The provider has no credential settings. It signs in with DefaultAzureCredential.
provider "keytos" {
  ezca_url = var.ezca_url
}

variables.tf

Defines your EZCA instance, CA, and a map of the certificates you want Terraform to manage.

variable "ezca_url" {
  description = "Your EZCA instance URL, such as https://portal.ezca.io or https://eu.ezca.io."
  type        = string
  default     = "https://portal.ezca.io"
}

variable "authority_id" {
  description = "The CAID from the CA's SSL Template Details page in EZCA."
  type        = string
}

variable "template_id" {
  description = "The Template ID from the CA's SSL Template Details page in EZCA."
  type        = string
}

variable "certificates" {
  description = "Certificates to issue, keyed by a short name. Every name must be a domain Terraform can access in EZCA."
  type = map(object({
    common_name          = string
    dns_names            = optional(list(string), [])
    ip_addresses         = optional(list(string), [])
    organization         = optional(string)
    validity_period      = optional(string, "2160h") # 90 days
    early_renewal_period = optional(string, "720h")  # 30 days
  }))

  validation {
    condition = alltrue([
      for cert in values(var.certificates) :
      can(regex("^[0-9]+h$", cert.validity_period)) && can(regex("^[0-9]+h$", cert.early_renewal_period))
    ])
    error_message = "Set validity_period and early_renewal_period in hours, such as \"2160h\" for 90 days."
  }
}

main.tf

Generates a private key and CSR for each certificate, then asks EZCA to sign it.

# Confirms the CA and SSL template exist and that Terraform's identity can reach them.
data "keytos_ezca_ssl_authority" "this" {
  authority_id = var.authority_id
  template_id  = var.template_id
}

# The private key is created by Terraform and is never sent to EZCA.
resource "tls_private_key" "this" {
  for_each = var.certificates

  algorithm = "RSA"
  rsa_bits  = 4096
}

resource "tls_cert_request" "this" {
  for_each = var.certificates

  private_key_pem = tls_private_key.this[each.key].private_key_pem

  subject {
    common_name  = each.value.common_name
    organization = each.value.organization
  }
}

resource "keytos_ezca_ssl_leaf_cert" "this" {
  for_each = var.certificates

  authority_id     = data.keytos_ezca_ssl_authority.this.authority_id
  template_id      = data.keytos_ezca_ssl_authority.this.template_id
  cert_request_pem = tls_cert_request.this[each.key].cert_request_pem

  validity_period      = each.value.validity_period
  early_renewal_period = each.value.early_renewal_period

  additional_subject_alternative_names = {
    # Clients check the SAN, not the common name, so always include the common name here.
    dns_names    = distinct(concat([each.value.common_name], each.value.dns_names))
    ip_addresses = each.value.ip_addresses
  }
}

outputs.tf

Exposes each certificate and its private key so you can deploy them.

output "certificates" {
  description = "Issued certificates, keyed by certificate name."
  value = {
    for name, cert in keytos_ezca_ssl_leaf_cert.this : name => {
      cert_pem          = cert.cert_pem
      serial_number     = cert.cert_serial_number
      thumbprint        = cert.cert_thumbprint_hex
      not_after         = cert.validity_not_after
      ready_for_renewal = cert.ready_for_renewal
    }
  }
}

output "private_keys_pem" {
  description = "Private keys for the issued certificates, keyed by certificate name."
  value       = { for name, key in tls_private_key.this : name => key.private_key_pem }
  sensitive   = true
}

terraform.tfvars

Your values. Replace the IDs with the CAID and Template ID from Step 3, and the domains with ones Terraform can access in EZCA.

ezca_url     = "https://portal.ezca.io"
authority_id = "00000000-0000-0000-0000-000000000000" # CAID
template_id  = "00000000-0000-0000-0000-000000000000" # Template ID

certificates = {
  web = {
    common_name  = "web.example.com"
    dns_names    = ["www.example.com"]
    organization = "Contoso"
  }
  api = {
    common_name          = "api.example.com"
    validity_period      = "720h" # 30 days
    early_renewal_period = "240h" # 10 days
  }
}

Durations use Go’s format, which has no unit for days, so write them in hours: 720h is 30 days, 2160h is 90 days, and 8760h is 365 days. EZCA issues certificates in whole days, so validity_period must be at least 24h, and early_renewal_period must be shorter than validity_period.

backend.tf

Stores Terraform state in Azure Storage so every pipeline run sees the same certificates. If you use HCP Terraform or another remote backend, replace this file with that backend’s configuration. For a quick test on your workstation, you can leave this file out and Terraform will keep its state locally.

terraform {
  backend "azurerm" {
    resource_group_name  = "rg-terraform-state"
    storage_account_name = "sttfstatecontoso" # must be globally unique
    container_name       = "tfstate"
    key                  = "ezca-certificates.tfstate"
    use_azuread_auth     = true # signs in with Entra ID instead of storage account keys
  }
}

If you don’t have a state storage account yet, create one with versioning turned on so you can recover an earlier state:

az group create --name rg-terraform-state --location eastus

az storage account create --name sttfstatecontoso --resource-group rg-terraform-state \
  --sku Standard_ZRS --min-tls-version TLS1_2 --allow-blob-public-access false

az storage account blob-service-properties update --account-name sttfstatecontoso \
  --resource-group rg-terraform-state --enable-versioning true

az storage container-rm create --storage-account sttfstatecontoso --name tfstate \
  --resource-group rg-terraform-state

Then give your Terraform identity, and any person who runs Terraform from a workstation, the Storage Blob Data Contributor role on the storage account:

az role assignment create --assignee "$APP_ID" --role "Storage Blob Data Contributor" \
  --scope "$(az storage account show --name sttfstatecontoso --resource-group rg-terraform-state --query id -o tsv)"

.gitignore

Keeps state, plans, and keys out of your repository.

.terraform/
*.tfstate
*.tfstate.*
tfplan
*.key
*.pem

Step 6: How to Deploy Your Certificates and Verify Them

Run your first deployment from your workstation to confirm that authentication and domain access work before you automate it.

  1. Sign in as described in Step 4.

  2. Navigate to your ezca-certificates folder and initialize Terraform. This downloads the Keytos and TLS providers and connects to your state backend:

    terraform init
    
  3. Preview the changes. Terraform reads your CA through the keytos_ezca_ssl_authority data source, so sign-in or CA ID problems show up here before any certificate is issued:

    terraform plan
    
  4. Issue your certificates:

    terraform apply
    
  5. Check the issued certificates:

    terraform output certificates
    
  6. (optional) Write a certificate and its key to files with jq, and inspect the certificate with OpenSSL:

    terraform output -json certificates | jq -r '.web.cert_pem' > web.crt
    terraform output -json private_keys_pem | jq -r '.web' > web.key
    openssl x509 -in web.crt -noout -subject -issuer -dates -ext subjectAltName
    

Done! Your certificates are issued by EZCA and managed by Terraform. The cert_pem output contains only the issued certificate. If your application needs the full chain, download your CA certificates from the EZCA portal and append them.

How to Use Your Certificates in Other Terraform Resources

Because the certificate and key are regular Terraform values, you can pass them straight to other resources in the same configuration. For example, this creates a Kubernetes TLS secret with the Kubernetes provider:

resource "kubernetes_secret_v1" "web_tls" {
  metadata {
    name      = "web-tls"
    namespace = "default"
  }

  type = "kubernetes.io/tls"

  data = {
    "tls.crt" = keytos_ezca_ssl_leaf_cert.this["web"].cert_pem
    "tls.key" = tls_private_key.this["web"].private_key_pem
  }
}

When the certificate renews, the next terraform apply updates the secret with the new certificate.

Step 7: How to Automatically Renew Your Certificates with a Scheduled GitHub Actions Pipeline

Terraform only renews a certificate when it runs, so the last piece is a pipeline that runs terraform apply on a schedule. This workflow runs every day, on every push to main, and on demand.

  1. In your GitHub repository, go to Settings > Secrets and variables > Actions > Variables, and add these repository variables. They are identifiers, not secrets:

    • AZURE_CLIENT_ID: your app registration’s client ID.
    • AZURE_TENANT_ID: your Entra ID tenant ID.
    • AZURE_SUBSCRIPTION_ID: the subscription that holds your state storage account.
  2. Make sure your app registration has the federated credential from Step 1 with the subject repo:<org>/<repo>:environment:production.

  3. Save the following workflow as .github/workflows/ezca-certificates.yml:

    name: EZCA Certificates
    
    on:
      push:
        branches: [main]
      schedule:
        - cron: "17 6 * * *" # every day at 06:17 UTC
      workflow_dispatch:
    
    permissions:
      id-token: write # lets the job request an OIDC token from GitHub
      contents: read
    
    concurrency:
      group: ezca-certificates
      cancel-in-progress: false
    
    jobs:
      terraform:
        runs-on: ubuntu-latest
        environment: production # must match the subject of your federated credential
        env:
          # The Keytos provider uses the Azure CLI session from azure/login.
          AZURE_TOKEN_CREDENTIALS: AzureCLICredential
          # The azurerm state backend signs in with the same app registration over OIDC.
          ARM_USE_OIDC: true
          ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
          ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
          ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
          TF_IN_AUTOMATION: true
        steps:
          - uses: actions/checkout@v7
    
          - name: Sign in to Entra ID
            uses: azure/login@v3
            with:
              client-id: ${{ vars.AZURE_CLIENT_ID }}
              tenant-id: ${{ vars.AZURE_TENANT_ID }}
              allow-no-subscriptions: true
    
          - uses: hashicorp/setup-terraform@v4
    
          - run: terraform init -input=false
    
          # Refreshing state renews any certificate inside its early renewal period.
          - run: terraform apply -input=false -auto-approve
    
  4. Commit and push the project to main. The workflow runs, and you can follow it from the repository’s Actions tab.

That’s it! Your certificates now renew themselves every time they enter their early renewal period, and every change goes through your normal pull request process.

We recommend adding required reviewers to the production environment if you want a person to approve changes. Keep in mind that scheduled renewals also wait for that approval.

How Certificate Renewal and Revocation Work with the Keytos Terraform Provider

The provider decides what to do with a certificate every time Terraform refreshes it:

When this happens The provider does this
Terraform refreshes a certificate that is inside its early_renewal_period, or has expired Requests a new certificate from the same CSR, so it keeps the same private key. The previous certificate stays valid until it expires.
You change authority_id, template_id, the CSR, validity_period, the key usages, the subject, or the SANs Revokes the current certificate and issues a new one.
You remove a certificate from your configuration, or run terraform destroy Revokes the certificate.

Follow these recommendations to keep renewals smooth:

  • Run terraform apply at least once a day. Set early_renewal_period to about a third of validity_period, so a failed run has plenty of time to be fixed before the certificate expires.

  • Run terraform apply, not only terraform plan. A plan that runs inside the early renewal period requests a new certificate but doesn’t save it to state, so the next run requests another one.

  • Rotate the private key by replacing it. Terraform creates a new key and CSR, then the provider revokes the old certificate and issues a new one:

    terraform apply -replace='tls_private_key.this["web"]'
    
  • Check before you remove a certificate. Deleting it from certificates revokes it right away, so make sure nothing still uses it.

Troubleshooting the Keytos Terraform Provider

The following errors are the most common when setting up the provider. Most come from the data source or resource, so they show up in terraform plan or terraform apply.

Error contains What it means and how to fix it
DefaultAzureCredential: failed to acquire a token No credential in the chain could sign in. Run az login, or check your environment variables. Set AZURE_TOKEN_CREDENTIALS to the credential you expect to see its specific error.
invalid AZURE_TOKEN_CREDENTIALS value The variable has a typo. Use dev, prod, or a credential name such as AzureCLICredential.
could not find SSL details The CAID or Template ID is wrong, or the template isn’t an SSL template. Copy both again from View Requirements in Step 3.
Expected a valid UUID authority_id or template_id isn’t a GUID. Paste the value exactly as EZCA shows it.
Invalid duration string validity_period or early_renewal_period uses a unit Go doesn’t support, such as 30d. Use hours, such as 720h.
duration must be in scale of days validity_period is shorter than one day. Use at least 24h.
Early renewal period greater than certificate duration Make early_renewal_period shorter than validity_period.
Error Signing or Error Renewing Certificate EZCA refused the request. Check that every name in the certificate is a registered domain, that Terraform’s identity has access to each one (Step 2), and that validity_period isn’t longer than the CA’s Maximum Certificate Validity Period.
Error Revoking Certificate Terraform’s identity can’t revoke certificates for this domain. Add it as a Domain Certificate Administrator.
instance must be reached with https Set ezca_url to an https:// URL, such as https://portal.ezca.io.

Still stuck? Don’t hesitate to reach out to our support team.

Next Steps - How to Automate More of Your PKI with EZCA

Now that Terraform manages your certificates, you can hand the bootstrap certificate to the EZCA Kubernetes Operator to keep certificates renewed inside your clusters, or let EZCA create and auto-renew certificates in Azure Key Vault for your Azure services.

🚀 Set Up the EZCA Kubernetes Operator

Enjoying EZCA? Leave Us a Review!

We hope you’re enjoying using EZCA to automate your certificates! If you have a moment, we would greatly appreciate it if you could leave us a review on G2. Your feedback helps other IT professionals discover EZCA and helps us continue to improve our service. Thank you for your support!