To add metadata for key "example-key" for a virtual machine instance named "example-instance" in project "example-project", run:
gdcloud compute instances add-metadata example-instance --project example-project --metadata=example-key="example value"
To add metadata under key "important-data" to an instance named "example-instance" using file "example-file"
gdcloud compute instances add-metadata example-instance --project example-project \
--metadata-from-file=important-data=example-file.txt
INDICATEURS FACULTATIFS
--metadata stringToString List of comma-separated key-value pair metadata to add to the virtual machine instance.
For example, --metadata=key1="val1",key2="val2". At least one of the flags --metadata or --metadata-from-file is required. (default [])
--metadata-from-file stringToString List of comma-separated KEY=LOCAL_FILE_PATH metadata to add to the virtual machine instance. The value of the key is read from the file provided.
For example, --metadata-from-file=key1=filepath1,key2=filepath2. At least one of the flags --metadata or --metadata-from-file is required. (default [])
OPTIONS GCLOUD GÉNÉRALES
Ces options sont disponibles pour toutes les commandes : --configuration, --format, --help, --project, --quiet.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003egdcloud compute instances add-metadata\u003c/code\u003e command is used to add metadata to a virtual machine instance.\u003c/p\u003e\n"],["\u003cp\u003eMetadata can be added using key-value pairs with the \u003ccode\u003e--metadata\u003c/code\u003e flag, where the values are specified directly.\u003c/p\u003e\n"],["\u003cp\u003eMetadata can also be added by specifying a local file path with the \u003ccode\u003e--metadata-from-file\u003c/code\u003e flag, where the file contents become the metadata value.\u003c/p\u003e\n"],["\u003cp\u003eAt least one of the \u003ccode\u003e--metadata\u003c/code\u003e or \u003ccode\u003e--metadata-from-file\u003c/code\u003e flags is required when using the command.\u003c/p\u003e\n"],["\u003cp\u003eCommon flags available for this command include \u003ccode\u003e--configuration\u003c/code\u003e, \u003ccode\u003e--format\u003c/code\u003e, \u003ccode\u003e--help\u003c/code\u003e, \u003ccode\u003e--project\u003c/code\u003e, and \u003ccode\u003e--quiet\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# gdcloud compute instances add-metadata\n\nNAME\n----\n\ngdcloud compute instances add-metadata - Add metadata for a virtual machine instance.\n\nSYNOPSIS\n--------\n\n gdcloud compute instances add-metadata INSTANCE_NAME [flags]\n\n### EXAMPLES\n\n To add metadata for key \"example-key\" for a virtual machine instance named \"example-instance\" in project \"example-project\", run:\n\n gdcloud compute instances add-metadata example-instance --project example-project --metadata=example-key=\"example value\"\n\n To add metadata under key \"important-data\" to an instance named \"example-instance\" using file \"example-file\"\n gdcloud compute instances add-metadata example-instance --project example-project \\\n --metadata-from-file=important-data=example-file.txt\n\n### OPTIONAL FLAGS\n\n --metadata stringToString List of comma-separated key-value pair metadata to add to the virtual machine instance.\n For example, --metadata=key1=\"val1\",key2=\"val2\". At least one of the flags --metadata or --metadata-from-file is required. (default [])\n --metadata-from-file stringToString List of comma-separated KEY=LOCAL_FILE_PATH metadata to add to the virtual machine instance. The value of the key is read from the file provided.\n For example, --metadata-from-file=key1=filepath1,key2=filepath2. At least one of the flags --metadata or --metadata-from-file is required. (default [])\n\n### GDCLOUD WIDE FLAGS\n\nThese flags are available to all commands: `--configuration`, `--format`, `--help`, `--project`, `--quiet`.\n\nFor more information, see the [gdcloud CLI reference overview](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-reference/gdcloud) page."]]