parsing the os-inventory metadata server struct
if you have os-inventory enabled, you can get the values on the VM itself by running
curl -s -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/guestInventory/InstalledPackages
parse the values using
(you can ofcourse otherwise get the packages via api