sincecutoff.com
← all changes

gcloud compute --metadata-from-file reads from standard input

Introduced 2026-10-06 · score 0.95

HOW TO USE IT

When metadata comes from standard input, pass `-` as the file path in `--metadata-from-file`. Use `KEY=-` on any of the four listed Compute commands.

printf '%s' '<metadata-value>' | gcloud compute instances add-metadata <INSTANCE_NAME> --zone=<ZONE> --metadata-from-file=<KEY>=-
printf '%s' '<metadata-value>' | gcloud compute project-info add-metadata --metadata-from-file=<KEY>=-
gcloud compute instances create <INSTANCE_NAME> --metadata-from-file=<KEY>=- < <INPUT_SOURCE>

WHY THIS HELPS

Set instance or project metadata from data produced on standard input.

REQUIREMENTS AND LIMITATIONS

  • --metadata-from-file=KEY=LOCAL_FILE_PATH (required): Sets a metadata value from a local file; use `-` as the path to read the value from standard input. For the add-metadata commands, at least one of `--metadata` or `--metadata-from-file` is required.
  • KEY (required): Metadata key paired with the input value.
  • INSTANCE_NAME (required): Instance to create or update.
  • --zone=ZONE: Instance zone; if omitted, gcloud may prompt or attempt to determine it from the active project.
  • The `-` file path reads the metadata value from standard input.
  • This applies to the four listed commands.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card