agentsclimarketplace

Yba terraform

Skill yugabyte/yugabytedb-skills/skills/yba-terraform

Use when writing, generating, or troubleshooting Terraform that drives YugabyteDB Anywhere (YBA) via the `yugabyte/yba` provider — installing YBA on a VM, registering the first customer, and creating cloud (AWS/GCP/Azure) or on-prem providers, storage configs, universes, backups, schedules, and restores. Also covers the upstream cloud Terraform (IAM user / service account / service principal) that grants YBA its node-deployment permissions, and the CLI commands to discover the VPC/subnet/security-group network info those manifests need. Triggers on `yba_installer`, `yba_customer_resource`, `yba_aws_provider`/`yba_gcp_provider`/`yba_azure_provider`, `yba_universe`, `yba_backup`, `source = "yugabyte/yba"`, or any mention of the YBA Terraform provider. Does NOT cover the YBA REST API directly (use the yba-api skill) or YugabyteDB Aeon.From its SKILL.md

Install
npx -y skills add yugabyte/yugabytedb-skills --skill yba-terraform

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

11.0 KB, as published. Nobody here has run it

YugabyteDB Anywhere (YBA) Terraform Provider

This skill generates correct Terraform for the yugabyte/yba provider — the official provider that installs and drives a self-managed YugabyteDB Anywhere control plane.

It is not about:

  • The YBA REST API directly — use the yba-api skill (this provider calls that API for you).
  • YugabyteDB Aeon (managed DBaaS) or YSQL/YCQL database access.

Reference files (read before generating non-trivial manifests)

  • references/prereqs-and-network.md — YBA host VM requirements (CPU/RAM/disk/OS/Python/ports), DB-node requirements, and the aws/gcloud/az CLI commands to discover VPC IDs, subnets-per-zone, security groups, and regions. Read this first when sizing a VM or filling in network IDs.
  • references/cloud-iam-setup.md — Terraform (using the aws/google/azurerm providers, not the yba provider) that creates the IAM user / service account / service principal YBA uses to deploy nodes, with the exact delegated permissions from the Yugabyte docs. Read this when the user needs to grant YBA cloud access.
  • references/install-bootstrap.md — the yba_installer and yba_customer_resource resources and the two-provider (unauthenticated → authenticated) pattern. Read this when installing YBA or wiring up the API token.
  • references/providers-universe.md — full HCL for yba_aws_provider / yba_gcp_provider / yba_azure_provider / yba_onprem_provider, the four storage-config resources, yba_universe, and yba_backup / yba_backup_schedule / yba_restore. Read this when generating any provider, universe, or backup resource.

The end-to-end workflow

A complete "from nothing to a running universe with backups" deployment is two Terraform stages because the API token does not exist until YBA is installed and the customer is registered.

┌─ Stage 0 (optional, upstream cloud TF) ── references/cloud-iam-setup.md
│   aws_iam_user / google_service_account / azuread_application
│   → the credentials YBA will use to deploy nodes
│
├─ Stage 1 (unauthenticated yba provider) ── references/install-bootstrap.md
│   yba_installer          → install YBA on an existing VM over SSH
│   yba_customer_resource  → register first customer; OUTPUTS api_token + cuuid
│
└─ Stage 2 (authenticated yba provider, api_token from stage 1) ── references/providers-universe.md
    yba_aws_provider / yba_gcp_provider / yba_azure_provider   (network info from references/prereqs-and-network.md)
    yba_s3_storage_config / yba_gcs_storage_config / ...
    yba_universe
    yba_backup_schedule / yba_backup / yba_restore

Run Stage 1 and Stage 2 as separate applys (or separate root modules / -target), because the api_token produced by yba_customer_resource must be known before the authenticated provider can be configured. Passing a provider api_token that is computed in the same apply is fragile — split the state.

Provider configuration (the two-provider pattern)

terraform {
  required_providers {
    yba = {
      source  = "yugabyte/yba"
      version = "~> 1.0"
    }
  }
}

# Stage 1: install + customer registration need NO token.
provider "yba" {
  alias = "unauthenticated"
  host  = var.yba_host   # IP or DNS, optionally :port
}

# Stage 2: everything else needs the customer API token.
provider "yba" {
  host      = var.yba_host
  api_token = var.yba_api_token   # from yba_customer_resource.<name>.api_token
}

The provider block accepts exactly three arguments — all optional, all env-var backed:

ArgumentEnv var (preferred → legacy)Notes
hostYBA_HOST → YB_HOSTIP/DNS, optionally with :port.
api_tokenYBA_API_TOKEN / YBA_API_KEY → YB_API_KEYCustomer API token. Omit for the unauthenticated provider.
enable_httpsYBA_ENABLE_HTTPS → YB_ENABLE_HTTPStrue by default. Set false for HTTP-only YBA (then put the HTTP port in host).

There is no api_key provider argument — YBA_API_KEY is only an env-var alias for api_token. With env vars set, the authenticated block can be empty (provider "yba" {}).

Resource cheat-sheet (use the per-cloud resources, not the deprecated generics)

PurposeResourceNotes
Install YBA on a VMyba_installerSSH-based; unauthenticated provider.
Register first customeryba_customer_resourceOutputs api_token, cuuid. destroy is a no-op.
Cloud provideryba_aws_provider, yba_gcp_provider, yba_azure_providerPrefer these. yba_cloud_provider is deprecated (removed in v2.0.0).
On-prem / VM provideryba_onprem_provider + yba_onprem_node_instancev1.0.0 has known on-prem issues — see reference file.
Backup storageyba_s3_storage_config, yba_gcs_storage_config, yba_azure_storage_config, yba_nfs_storage_configyba_storage_config_resource is deprecated.
Universeyba_universeReferences provider via provider, region_list, plus yba_provider_key + yba_release_version data sources.
Backupsyba_backup (on-demand), yba_backup_schedule (cron/frequency)yba_backups is deprecated → use yba_backup_schedule.
Restoreyba_restoreUses backup_storage_info { keyspace = ... } (singular).

Useful data sources: yba_provider_key, yba_release_version, yba_universe_schema (keyspace/table discovery for backups), yba_storage_configs, yba_provider_regions, yba_backup_info.

Getting the network info a cloud provider needs

yba_aws_provider / yba_azure_provider need VPC/vnet IDs, subnet IDs per zone, and a security group; yba_gcp_provider needs the network and a regional subnet (GCP zones auto-discover). Before generating a provider manifest:

  1. Check memory / the conversation for already-known VPC, subnet, region, and project/subscription IDs.
  2. If unknown, run the discovery CLI commands in references/prereqs-and-network.md (aws ec2 describe-subnets …, gcloud compute networks subnets list …, az network vnet subnet list …) and read the IDs from the output.
  3. If the user has no cloud CLI configured and the info isn't in memory, ask the user for the region(s), VPC/vnet ID, subnet ID per availability zone, and security-group ID — list exactly what's missing rather than inventing placeholder IDs that will fail at apply.

Never invent real-looking IDs (vpc-0123…, subnet-…). Use clearly-templated placeholders (<aws-vpc-id>) only when explicitly producing a template the user will fill in.

Prerequisites (always state these when planning an install)

The YBA host VM (official minimums, from the Yugabyte docs):

  • 4 vCPU, 8 GB RAM, x86_64 only (ARM is not supported for the YBA host).
  • Disk: 215 GB minimum. Provision a 250 GB root volume (or a dedicated filesystem mounted at YBA's data dir, default /opt/yugabyte/data) to leave headroom — a too-small root volume is the most common install failure.
  • A supported Linux OS (AlmaLinux 8/9, RHEL 8/9, Rocky 8/9, Oracle Linux 8, Ubuntu 20/22, Amazon Linux 2023, SLES 15 SP5). AlmaLinux 8 / RHEL 8 recommended for production.
  • Python 3.10–3.12, with both python and python3 resolving to Python 3.
  • A YBA license file from Yugabyte, and sudo access for the SSH user (YBA Installer also supports non-root mode).

Full host + DB-node requirements and the port list are in references/prereqs-and-network.md.

Anti-patterns

Anti-patternConsequenceDo instead
Configuring the authenticated provider with an api_token computed in the same applyProvider config can't depend on a not-yet-known value; flaky/failed applySplit into Stage 1 (install + customer) and Stage 2 (everything else); pass the token between states/modules.
Using yba_cloud_provider / yba_storage_config_resource / yba_backupsDeprecated; removed in v2.0.0Use yba_aws_provider/…, the per-backend *_storage_config, and yba_backup_schedule.
Adding a nested zones {} block to yba_gcp_providerSchema error — GCP has no per-zone blockGCP: regions { code, shared_subnet }; zones auto-discover. AWS/Azure use zones { code, subnet }.
Putting AMI IDs in region_overrides for GCP/AzureWrong fieldAWS uses image_bundles.details.region_overrides (map); GCP/Azure use details.global_yb_image (string). Or use yba_managed_image_bundles.
Hard-coding a 215 GB / smaller root volumeInstall runs out of space mid-deployProvision 250 GB; YBA data lives in /opt/yugabyte/data.
Using keyspaces on yba_restoreSchema errorRestore uses repeatable backup_storage_info { keyspace = ... } (singular); backups/schedules use keyspaces (list).
device_info with storage_type = "GP3" but no disk_iops/throughputPasses validate, fails plan — GP3 requires both (IO1/IO2 require disk_iops)Set disk_iops and throughput for GP3 (baseline 3000 / 125). See the device_info table in providers-universe.md.
Trusting a clean terraform validateThe yba provider enforces many cross-field rules only at plan timeAlways run terraform plan — validate checks schema shape, not the provider's conditional requirements.
Granting YBA broad cloud adminOver-privileged credentialsApply the scoped policy/role in references/cloud-iam-setup.md (AWS JSON policy, GCP roles/compute.admin, Azure Network + VM Contributor).
Committing state with api_token/password in plaintextCredential leak — token does not expireUse an encrypted remote backend; mark vars sensitive.
Expecting terraform destroy to remove the customeryba_customer_resource destroy is a no-op (no delete-customer API)Understand it only drops from state; the YBA customer persists.

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.