Skip to content

Yandex Cloud ​

Status: available · package wg-flow-plugin-yandex 0.1.0 · provider yandex · category cloud.

The plugin reads one Yandex Cloud folder. Inventory receives virtual machines, disks, VPC networks, reserved public IPs, security groups, and load balancers. The secret stays in the agent YAML.

Compute and VPC do not accept an API key. The agent obtains an IAM token and calls the APIs with Authorization: Bearer. For a service account it signs a JWT with the authorized key JSON (yc iam key create) and refreshes the IAM token while that key is valid. An OAuth token is exchanged the same way. A ready IAM token (t1.) is accepted, but it lasts about 12 hours and is not refreshed.

One source is one folder. The folder id is in the console URL. The service account, or the user behind the OAuth token, needs the viewer role on that folder.

The plugin only reads the API.

Images, snapshots, instance groups, filesystems, Managed Kubernetes, managed databases, Object Storage, Certificate Manager, Cloud DNS, Lockbox, and KMS are not read in 0.1.0. Instance metadata (SSH keys, user-data) is not copied into inventory. A 403 or 404 from a load balancer API yields an empty list and does not fail the source. Any other list error fails the whole source, so a partial snapshot is not sent.

Install ​

The agent must be connected to the API.

bash
docker compose exec agent wg-flow-agent plugin install yandex
# or
wg-flow-agent plugin install yandex

Then the local UI → Connections → yandex, or YAML.

Service account key:

bash
yc iam key create --service-account-id <id> --output key.json

An OAuth token for a Yandex user is described in the Yandex Cloud docs. The CLI flow opens https://oauth.yandex.ru/authorize?response_type=token&client_id=1a6990aa636648e9b2ef855fa7bec2fb — the token is in the redirect URL.

What lands in inventory ​

Yandex Cloud objectresource_typeNotes
Virtual machineinstanceprovider_resource_id = instance:{id}. RUNNING → active, STOPPED → stopped, transitional states and DELETING → pending, ERROR and CRASHED → error. Region is the zone (ru-central1-a). Public IPv4 from one-to-one NAT → metadata.primary_ipv4, internal addresses → metadata.private_ips. vCPU, memory, and core fraction are cpu_cores, mem_gb, core_fraction. When disks are collected in the same run, the boot disk size is disk_gb
Diskstoragedisk:{id}. READY → active, CREATING → pending. Size in metadata.disk_gb and metadata.size_gb. Type is disk_type
Networknetworknetwork:{id}. Subnet CIDRs from this folder in metadata.ip_ranges
Subnet of another networknetworksubnet:{id}, metadata.product = subnet. This keeps the address plan when the network lives in another folder
Public IPnetworkaddress:{id}. metadata.product = public_ip. Address in metadata.primary_ipv4
Security groupfirewallfirewall:{id}. Metadata stores the rule count, not the rules
Network load balancerload_balancernlb:{id}. ACTIVE → active, STOPPED and INACTIVE → stopped
Application load balancerload_balanceralb:{id}. Same statuses

Inventory has no separate ip type, so a public address is a network.

Each collect flag can be turned off. A disabled slice is not requested and is absent from the next successful sync, and inventory marks those rows inactive. An instance gets disk_gb only when disk collection is on.

Several folders mean several sources. provider_account is your label.

YAML ​

yaml
plugins:
  yandex:
    enabled: true
    sources:
      - id: prod
        provider_account: "yc-prod"
        sync_interval_seconds: 300
        folder_id: "b1g…"
        auth_type: "authorized_key"
        authorized_key: "{\"id\":\"aje…\",\"service_account_id\":\"aje…\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\n…\"}"
        collect_instances: true
        collect_disks: true
        collect_networks: true
        collect_addresses: true
        collect_firewalls: true
        collect_load_balancers: true

OAuth instead of a key: auth_type: oauth and a token. An IAM token t1. uses the same field.

Source fields ​

FieldRequiredDescription
idyesLog key (yandex/prod)
provider_accountyesFolder label in inventory
folder_idyesFolder id
auth_typenooauth (default) or authorized_key
tokenfor oauthOAuth token or IAM t1.
authorized_keyfor a keyThe whole authorized key JSON
collect_*noDefault true
sync_interval_secondsnoMinimum 300

Check ​

bash
wg-flow-agent status
wg-flow-agent dry-run

JSON shows provider: yandex. Health obtains an IAM token and lists instances with pageSize=1. The key and token are not written to inventory.

Common errors ​

SymptomWhat to check
401The OAuth token is still valid, or the key JSON has id, service_account_id, and private_key. An API key does not work here
403 on the folderThe account has viewer on this folder_id
IAM token expiredt1. is not refreshed. Use OAuth or an authorized key
Empty instance listcollect_instances is on and the VMs are in this folder
No disk_gb on a VMcollect_disks is off, so the disk size was not requested
No load balancersMissing NLB or ALB permission — the source still succeeds
Disks disappeared after synccollect_disks was turned off; inventory retires the missing rows