ankraio/ankra on the Terraform Registry, manages what the Ankra CLI can create, change or delete: clusters on your cloud, managed Kubernetes, node groups, credentials, Helm registries, variables, alerts, DNS, applications, pipelines, stack profiles, backups, members, tokens and organisation settings. The Registry carries the generated reference for every resource and attribute.
This page describes provider 0.3.0, which brings the provider to parity with the CLI: 97 resources and 42 data sources. On 0.2.x only the six cluster resources and the
ankra_clusters data source exist. Check the version you can install on the Registry before you use a resource from What you can manage, and read Upgrade from 0.2.x before you upgrade.Configure the provider
The provider needs Terraform 1.0 or newer (it is tested with 1.6 to 1.12).
If no token reaches a resource, from the provider or the deprecated per-resource
ankra_token, Terraform stops with Missing API token and sends no request.
Projects and organisations
Withoutproject_id, Ankra scopes every request to the project your user last selected in the UI, so switching project there would change what Terraform sees. The resources added in 0.3.0 therefore refuse to run in an organisation with more than one project until the provider sets project_id, and they send nothing until it does.
When organisation_id or project_id changes, an object Terraform created in the old scope is reported as not visible in the provider’s current scope. It is not planned for recreation, and terraform destroy does not report it destroyed while it still exists. Point the provider back at the old scope to manage it, or run terraform state rm to stop managing it.
If organisation_id or project_id is only known after apply (for example, it comes from another resource), the provider sends no request until it is known instead of acting in your default organisation or project.
What you can manage
Each name links to its reference on the Registry through the provider’s documentation index.
Operational commands stay in the CLI: logs,
exec, metrics, pipeline runs and reruns, cluster scale, cluster upgrade, chat and the AI board. Stack variables, managed services, stack profile drafts, restore points and migrations have no Terraform resource either.
Create a cluster on your cloud
The cloud cluster resources share most arguments and each keeps its cloud’s own words for size and place.
AWS, Proxmox, Morpheus and Ankra Cloud follow the same pattern; their Registry pages list each one’s required arguments.
Optional arguments every cloud resource takes:
A cluster’s own provisioning arguments force replacement: change
worker_count or a size on the cluster resource and the plan destroys and recreates the cluster. To add capacity, add or change an ankra_node_group, or scale with the CLI or the UI. Read every plan before you apply it.
terraform destroy asks Ankra to deprovision the cluster and remove what it created in your cloud account, and on AWS, Proxmox, Morpheus and Ankra Cloud it waits until the cluster is gone. force_destroy skips the platform’s usual guards: it is true by default on Hetzner, DigitalOcean, OVHcloud, UpCloud and Scaleway and false on the others. On AWS and Ankra Cloud, Ankra refuses to delete a cluster that still holds persistent volumes unless you set accept_volume_data_loss = true.
To use credentials you already created, find their IDs with the CLI. The ID column of ankra credentials list holds credential_id, and the provider’s ssh-key list holds ssh_key_credential_id:
Node groups
ankra_node_group adds a group of workers to a cluster Ankra built. node_count, instance_type, labels, taints and autoscaling change in place. An instance_type change drains and power-cycles each node, and the apply waits until every node is back on the new type.
Managed Kubernetes
ankra_managed_cluster creates a cluster on DigitalOcean (DOKS), UpCloud (UKS), Google (GKE), Azure (AKS), AWS (EKS), OVHcloud (MKS), Scaleway (Kapsule) or Ankra Cloud Kubernetes and connects it to Ankra. Options specific to one provider go in provider_options.
node_pools is a map keyed by pool name. node_count and autoscaling change in place, adding a key adds a pool and removing one deletes it. To change a pool’s size, give it a new key: the new pool is added, and the old one is deleted only after the new pool’s nodes are ready. Ankra cannot check pool readiness on UKS and OVHcloud MKS, so there both pools are kept and the apply stops with an explanation. Other changes to an existing pool are refused at plan time. ankra_managed_node_pool manages a pool outside the cluster resource.
destroy_mode decides what terraform destroy does: delete_provider_cluster deletes the cluster at the provider, disconnect only removes it from Ankra. Clusters this resource created default to deleting, imported ones to disconnecting. wait_for_agent = true waits until the Ankra agent is online.
Register a cluster you already run
ankra_cluster registers a cluster you operate yourself, the same way an ImportCluster file does, and keeps its Stacks in Terraform.
How the Stack fields work:
parentsorders deployment. Write each entry as"manifest:<name>"or"addon:<name>". A bare"<name>"works when exactly one manifest or add-on of that name is declared in the resource. Leavingparentsout keeps the order already stored in Ankra; an empty list removes it.registry_urlis the Helm repository that serves the chart (https://...oroci://...).registry_nameis the name of that Helm registry in your organisation, whichankra_helm_registrycan create. If you leave it out, the provider derives a name from the URL, which Ankra accepts when a registry with that URL is already connected. Setregistry_credential_name(anankra_helm_registry_credential) for a private registry.data.ankra_helm_chartgives thelatest_versionof a chart if you want to pin to it.configurationholds the Helm values, as YAML or base64-encoded YAML.job_configurationis a JSON object of timeouts in seconds:create_job_timeout,read_job_timeout,update_job_timeoutanddelete_job_timeout. Build it withjsonencode.- Stack variables you set in the UI or the CLI are kept when the resource applies the Stack.
parents and job_configuration at plan time. If Ankra refuses the Stack, the error names the member and the field.
Run
helm_command against the cluster to connect it. Terraform cannot run it inside the cluster for you, but a remote-exec provisioner on a host that can reach the cluster can:
terraform output -raw agent_install_command:
cluster_name already exists, creating the resource adopts it: Ankra updates that cluster with your configuration and Terraform manages it from then on. Because the agent command is only issued on first registration, helm_command is empty for an adopted cluster, and Terraform prints a warning saying so. Copy the command from the Ankra UI if you need it.
terraform destroy deletes the cluster from Ankra.
Secrets, tokens and settings
- Secrets are write-only. API tokens, keys, passwords and webhook URLs are marked sensitive, and Ankra never returns them, so a secret changed outside Terraform is not detected. Terraform state still holds the value you configured, so keep state in an encrypted backend. On Terraform 1.11 and newer,
ankra_application_env_secrettakesvalue_wo, which is never stored in state. - Values shown once (the token of
ankra_api_tokenandankra_service_token, a registry robot’s secret, a generated SSH private key,ankra_host_join_token) are captured into state when they are created. - Changing a token’s expiry, scopes, label or project mints a new token value. The provider creates the new token before it removes the old one, so there is no gap, but every holder needs the new value. An empty
scopeslist is refused because Ankra reads it as full access. A member’s or service account’s role is changed in the UI, not in Terraform. - Settings resources (
ankra_ci_settings,ankra_ai_environment,ankra_ai_spend_cap,ankra_cluster_agent_ci_settings,ankra_cost_settings,ankra_cost_autopilot) write only the attributes you set and reset only those on destroy. Some refuse to create over settings already changed in the UI; import those instead. - Applications. Creating
ankra_applicationopens a setup pull request on its repository, which Ankra merges for you ifankra_application_settings.auto_merge_setup_pull_requestsis on. Replacing an application removes every deployment of it, so considerlifecycle { prevent_destroy = true }.ankra_pipeline_definitionis for repositories without a committed.ankra/pipeline.yaml. - Data protection. The plan refuses a change that would replace a backup vault or bucket while
destroy_provider_resources = true, because the replacement would delete its data.
Import existing objects
Every resource imports, most by their Ankra ID and cluster-scoped ones by<cluster_id>/<key>. Each resource’s Registry page shows its import ID.
ankra_host_join_token cannot be imported.
Readiness and timeouts
Keep the wait on when anything in the same plan uses the cluster, such as a kubeconfig, a
kubernetes provider or a module, because provisioning runs in the background. The cluster ID is saved to state before the wait starts, so a timeout reports how far the cluster got without losing track of it.
Known limits
- Changing
github_repositoryorgithub_branchon an existingankra_clusterfails with a 409 error. Ankra refuses to move a cluster to a different GitOps source until the move is acknowledged, and the provider has no argument for that yet. Make the move outside Terraform as described underspec.git_repositoryin the ImportCluster reference, then update your configuration to match. helm_commandis empty for an adopted cluster, and when Ankra queued the import instead of running it.- Resizes made outside Terraform to a cluster’s own arguments are not detected. Node groups and managed node pools do refresh.
- Secrets changed outside Terraform are not detected. See Secrets, tokens and settings.
- Stack variables cannot be managed from Terraform yet. Use cluster or organisation variables, or the Stack itself.
Upgrade from 0.2.x
- Set
project_idon the provider if your organisation uses projects. See Projects and organisations. - Imports of the original five cloud clusters now adopt your configuration on the first apply instead of planning a rebuild. Make the configuration match the real cluster first.
- Read the first plan. Plan-time checks are stricter: values Ankra would refuse at apply now fail the plan instead.
Upgrade from 0.1.x
0.1.6 cannot create or update a cluster against the current Ankra API, so upgrade before you use the provider. Before you runterraform init -upgrade:
- Pin
distributionandcnion cloud resources. Both now default tokubeadmandcilium, and both force replacement. If a cluster was created with the old k3s and flannel defaults, adddistribution = "k3s"andcni = "flannel"first, or the next plan replaces it. - Use Terraform 1.0 or newer. The provider runs on Terraform plugin protocol 6.
- Move the token to the provider. Set
tokenon the provider block orANKRA_TOKEN. The per-resourceankra_tokenstill works but is deprecated, and changing it no longer replaces the cluster. - Update add-ons. Replace
repository_urlwithregistry_url(the old name still works) and addregistry_name. Writejob_configurationasjsonencode({ ... }).configuration_typeis ignored. - Update
parents. Use"manifest:<name>"or"addon:<name>", or a bare name that matches exactly one member of the resource. - Rotate agent tokens printed by 0.1.x.
helm_commandcontains a live agent token and 0.1.x did not mark it sensitive. If a plan or CI log printed it, rotate that token.
terraform plan and check it reports no replacement you did not expect.
The full list of changes is in the provider’s changelog.