Skip to content

terraform_main

terraform/main.tf is the cloud half of the bundle. It creates the identities your node runs as and the permissions those identities hold, on whichever of the three providers you named.

Terraform is the execution backend, and the provider adapters are the translation boundary between the install contract and provider Terraform resources.

What it looks like

Prepared for dp-eu-west1 on GCP, in project <gcp-project-id>, region <region>:

terraform {
  required_providers {
    google = { source = "hashicorp/google", version = "~> 5.0" }
  }
}

provider "google" {
  project = "<gcp-project-id>"
  region  = "<region>"
}

resource "google_service_account" "runtime" {
  account_id   = "dp-eu-west1-runtime"
  display_name = "Xratu dataplane runtime"
}

resource "google_service_account" "build" {
  account_id   = "dp-eu-west1-build"
  display_name = "Xratu dataplane build"
}

resource "google_service_account" "publish_delegate" {
  account_id   = "dp-eu-west1-build-publish"
  display_name = "Xratu dataplane publish delegate"
}

resource "google_project_iam_member" "runtime_artifact_registry_writer" {
  project = "<gcp-project-id>"
  role    = "roles/artifactregistry.writer"
  member  = "serviceAccount:dp-eu-west1-runtime@<gcp-project-id>.iam.gserviceaccount.com"
}

resource "google_artifact_registry_repository_iam_member" "publish_delegate_repository_writer" {
  project    = "<gcp-project-id>"
  location   = "<region>"
  repository = "<repository>"
  role       = "roles/artifactregistry.writer"
  member     = "serviceAccount:dp-eu-west1-build-publish@<gcp-project-id>.iam.gserviceaccount.com"
}

Further resources follow the same shape: bucket access for runtime and build, a token-creator grant from build onto the publish delegate, and a workload identity binding per Kubernetes service account.

Every identity name is derived from dp_install, which is what keeps two installations in one project from colliding.

What it creates on every provider

Resource Purpose
A runtime cloud identity What xratud and its workloads act as
A build cloud identity What builds act as
A publish delegate identity What build impersonates to push to the registry
Registry access Push and pull against your tenant artifact registry
Bucket access Read and write against your tenant artifact bucket
A federation binding per Kubernetes service account Lets the in-cluster service account assume the cloud identity

Runtime and build are separated from the start because they have different reach, and publishing is delegated further still rather than granted to build directly.

What differs per provider

GCP AWS Azure
Mode gcp_workload_identity aws_irsa azure_workload_identity
Required inputs project_id, region account_id, region, cluster_oidc_issuer, cluster_oidc_provider_arn subscription_id, tenant_id, location, resource_group, aks_oidc_issuer, artifact_registry_scope
Service account annotation iam.gke.io/gcp-service-account eks.amazonaws.com/role-arn azure.workload.identity/client-id
Generated identities Two GSA principals Two IAM roles Two user-assigned managed identities
Registry grant Artifact Registry writer ECR push and pull policy ACR AcrPush role assignment
Federation WorkloadIdentityUser binding to each KSA AssumeRoleWithWebIdentity trust per KSA Federated identity credential per KSA

AWS asks for more than the others because IRSA needs the cluster's OIDC issuer and provider ARN, which the other two derive. See Cluster OIDC values.

The provider is a closed set of gcp, aws and azure, and the workflow above it is identical on all three: the same commands, the same spec shape, the same stages. Provider-specific materialisation sits behind the adapter.

The permission profile it grants

The baseline covers tenant-owned resources:

Included. Runtime and build push and pull against the tenant artifact registry, and read and write against the tenant artifact bucket.

Explicit add-ons. Private upstream registries, external buckets and object stores, and third-party tokens are separate profiles you grant deliberately. The baseline is a tenant-scoped grant rather than an ambient one.

How it runs

apply runs Terraform in the bundle's terraform directory. Terraform reads the files in that directory, so an edit you make to main.tf after prepare is what runs.

A Terraform failure stops the apply and reports the command and the error:

dataplane install terraform command failed (terraform apply -auto-approve):
<terraform error>

Nothing downstream runs, so a cloud failure leaves the cluster untouched rather than half-configured.

Reviewing before it runs

prepare generates for review and apply executes. On a cloud where your organization has its own IAM conventions, prepare, read main.tf, make the edits, then apply. See Editing generated files and the per-cloud pages: GCP, AWS, Azure.