Ankra terraform

From ankraio/ankra-cli · View interactive version

Ankra terraform is an AI agent skill from the GitHub repository ankraio/ankra-cli. Manage Ankra with the Ankra Terraform provider (ankraio/ankra) - provider configuration (token, organisation_id, project_id), clusters on every lane (Hetzner, DigitalOcean, OVHcloud, UpCloud, Scaleway, AWS, Proxmox, Morpheus, Ankra Cloud), managed Kubernetes and node pools, node groups, imported clu

How to use this skill

Skill file

Ankra Terraform Provider

The provider is published on the Terraform Registry as ankraio/ankra. Since 0.3.0 it covers what the ankra CLI can create, change or delete: 97 resources and 42 data sources. On 0.2.x only the six cluster resources and ankra_clusters exist; everything else on this page needs 0.3.0 or later. Check which version the user can install (terraform providers or the Registry) before writing HCL for a newer resource. Describe the provider exactly as here: do not invent arguments, and check the Registry docs for each resource's full schema.

Operational commands stay in the CLI: logs, exec, metrics, runs and reruns, cluster scale, cluster upgrade, chat, the AI board. Never wrap them in local-exec.

Recommended path

This is the infrastructure as code golden path in ankra-platform-principles: use the provider when the organisation already runs Terraform; otherwise GitOps as the source of truth (ankra-gitops, ankra cluster apply) is the default. Keep one source of truth per object: a given cluster's Stacks live in GitOps YAML or in ankra_cluster, never both, and nothing Terraform manages is also changed in the portal or with the CLI. Applications still ship through ankra-ship and Ankra Pipelines; Terraform declares them, it does not replace the pipeline.

Provider block

terraform {
  required_providers {
    ankra = {
      source  = "ankraio/ankra"
      version = "~> 0.3.0"
    }
  }
}

provider "ankra" {
  project_id = var.ankra_project_id # required in organisations with more than one project
}

variable "ankra_project_id" {
  type = string
}

What exists (0.3.0, plus 0.5.0 where marked)

| Area | Resources | Data sources |

|---|---|---|

| Clusters Ankra builds | ankra_hetzner_cluster, ankra_digitalocean_cluster, ankra_ovh_cluster, ankra_upcloud_cluster, ankra_scaleway_cluster, ankra_aws_cluster, ankra_proxmox_cluster, ankra_morpheus_cluster, ankra_ankracloud_cluster, ankra_playground | ankra_clusters, ankra_cluster, ankra_kubernetes_versions, ankra_playground_plans |

| Managed Kubernetes (DOKS, UKS, GKE, AKS, EKS, OVHcloud MKS, Kapsule, Ankra Cloud Kubernetes) | ankra_managed_cluster, ankra_managed_node_pool | |

| Node groups | ankra_node_group | ankra_node_groups |

| Imported clusters and Stacks | ankra_cluster | |

| Credentials | ankra_{hetzner,digitalocean,upcloud,ovh,scaleway,azure,ankracloud,morpheus,proxmox}_credential, ankra_aws_role_credential, ankra_aws_keys_credential, ankra_ssh_key_credential | ankra_credentials, ankra_credential |

| Helm and variables | ankra_helm_registry, ankra_helm_registry_credential, ankra_organisation_variable, ankra_cluster_variable | ankra_helm_registries, ankra_helm_registry_credentials, ankra_helm_chart, ankra_organisation_variables, ankra_cluster_variables |

| Cluster settings | ankra_cluster_access_grant, ankra_cluster_ssh_keys, ankra_cluster_custom_dns_zone, ankra_cluster_power_schedule, ankra_cluster_agent_auto_upgrade, ankra_cluster_agent_ci_settings, ankra_cluster_log_shipping, ankra_cluster_mesh, ankra_cluster_mesh_member | ankra_cluster_access_grants, ankra_cluster_custom_dns_zones, ankra_cluster_power_schedules, ankra_cluster_meshes |

| Alerts and DNS | ankra_alert_destination, ankra_alert_route, ankra_organisation_dns_record, ankra_organisation_custom_dns_zone, ankra_organisation_domain, ankra_dns_credential, ankra_cloudflare_credential, ankra_cloudflare_dns_record | ankra_alert_destinations, ankra_alert_routes, ankra_organisation_dns_zone, ankra_organisation_dns_records, ankra_organisation_custom_dns_zones, ankra_dns_credentials, ankra_cloudflare_credentials, ankra_cloudflare_domains |

| Applications and pipelines | ankra_application, ankra_application_settings, ankra_application_auto_deploy, ankra_application_ai_config, ankra_application_demo_config, ankra_application_env_secret, ankra_application_deployment, ankra_pipeline_repository, ankra_pipeline_definition, ankra_pipeline_schedule, ankra_pipeline_merge_train | ankra_applications, ankra_application, ankra_pipeline_repositories |

| Stack profiles, backups, image registry | ankra_stack_profile, ankra_stack_profile_version, ankra_stack_profile_share, ankra_stack_profile_logo, ankra_backup_vault, ankra_object_storage_bucket, ankra_registry_project, ankra_registry_robot, ankra_registry_retention | ankra_stack_profiles, ankra_backup_vaults, ankra_object_storage_buckets, ankra_registry_projects, ankra_registry_robots |

| Organisation and access | ankra_organisation, ankra_organisation_member, ankra_project (0.5.0), ankra_oidc_trust_policy (0.5.0), ankra_api_token, ankra_service_token, ankra_mcp_server, ankra_mcp_tool_grant, ankra_ci_settings, ankra_ci_pool_member, ankra_ai_review_repository, ankra_ai_review_related_repository, ankra_ai_spend_cap, ankra_ai_environment | ankra_organisation, ankra_organisations, ankra_mcp_servers, ankra_projects, ankra_project, ankra_oidc_trust_policies, ankra_cluster_access_policy (all 0.5.0) |

| AI, cost, security, services, targets | ankra_ai_provider, ankra_ai_anthropic_key, ankra_ai_openrouter_key, ankra_ai_openai_compatible, ankra_ai_endpoint, ankra_ai_model, ankra_ai_lane_model, ankra_ai_board_identity, ankra_cost_budget, ankra_cost_autopilot, ankra_cost_autopilot_override, ankra_cost_settings, ankra_security_disposition, ankra_security_compliance_framework, ankra_security_report_schedule, ankra_service_placement_policy, ankra_service_consumer, ankra_host_join_token | ankra_ai_models, ankra_ai_endpoints, ankra_ai_lanes, ankra_cost_budgets, ankra_security_compliance_frameworks, ankra_host_targets, ankra_deploy_environments |

Projects and GitHub OIDC trust (provider 0.5.0). These belong to the organisation and need no provider project_id, however many projects exist.

resource "ankra_project" "payments" {
  name = "Payments"
  slug = "payments" # immutable on the platform: changing it replaces the project
}

resource "ankra_service_token" "payments_ci" {
  name       = "payments-ci"
  role_slug  = "member"
  project_id = ankra_project.payments.id # pin the CI token to the project
}

resource "ankra_oidc_trust_policy" "deploy" {
  name                = "payments-deploy"
  repository_owner    = "my-org"
  repository_name     = "payments"
  repository_owner_id = 1234567  # gh api users/my-org --jq .id
  repository_id       = 89012345 # gh api repos/my-org/payments --jq .id
  ref                 = "refs/heads/main" # pin ref, environment or job_workflow_ref above viewer
  role_slug           = "operator"
}

Not available as Terraform: stack variables (stack-scoped ankra cluster stacks variables; use cluster or organisation variables, or the stack's own YAML), managed services setup, stack profile builder drafts, restore points and restores, migrations, and every operational command above.

A cluster from scratch

resource "ankra_hetzner_credential" "main" {
  name      = "hetzner-main"
  api_token = var.hcloud_token
}

resource "ankra_ssh_key_credential" "ops" {
  name           = "ops"
  ssh_public_key = file(pathexpand("~/.ssh/id_ed25519.pub"))
}

resource "ankra_hetzner_cluster" "prod" {
  name          = "prod"
  credential_id = ankra_hetzner_credential.main.id
  location      = "fsn1"

  ssh_key_credential_id = ankra_ssh_key_credential.ops.id

  control_plane_count       = 3
  control_plane_server_type = "cpx32"
  worker_count              = 2
  worker_server_type        = "cpx32"

  gitops_repository      = "my-org/platform-gitops"
  gitops_branch          = "main"
  gitops_credential_name = "my-github-credential"
}

resource "ankra_node_group" "gpu" {
  cluster_id    = ankra_hetzner_cluster.prod.cluster_id
  name          = "gpu"
  instance_type = "cpx42"
  node_count    = 2
  labels        = { accelerator = "gpu" }
}

resource "ankra_cluster_variable" "domain" {
  cluster_id = ankra_hetzner_cluster.prod.cluster_id
  name       = "ingress_domain"
  value      = "apps.example.com"
}

variable "hcloud_token" {
  type      = string
  sensitive = true
}

Clusters

`ankra_cluster` (an existing cluster and its Stacks)

resource "ankra_helm_registry" "traefik" {
  name = "traefik"
  url  = "https://traefik.github.io/charts"
}

resource "ankra_cluster" "prod" {
  cluster_name           = "my-cluster"
  github_credential_name = "my-github-credential"
  github_repository      = "my-org/my-repo"
  github_branch          = "main"

  stacks {
    name = "ingress"

    manifests {
      name            = "traefik-namespace"
      manifest_base64 = base64encode(file("${path.module}/traefik-namespace.yaml"))
    }

    addons {
      name              = "traefik"
      chart_name        = "traefik"
      chart_version     = "37.1.1"
      registry_name     = ankra_helm_registry.traefik.name
      registry_url      = ankra_helm_registry.traefik.url
      namespace         = "traefik"
      parents           = ["manifest:traefik-namespace"]
      configuration     = file("${path.module}/traefik-values.yaml")
      job_configuration = jsonencode({ create_job_timeout = 600 })
    }
  }
}

Rules that hold across resources

Import

Every resource imports, usually by its ID; cluster-scoped objects by <cluster_id>/<key> and managed clusters by <provider_name>/<cluster_id> (the Registry docs list each format). Cluster resources and credentials adopt the configured build arguments and secrets on the first apply after an import instead of planning a replacement, because the platform does not return them: write the configuration to match the real object before applying. ankra_host_join_token cannot be imported.

Known limits

Upgrading

Rules

Related skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.