When creating a Google Cloud virtual machine, you can choose to leave the Network Service Tier at the default setting of Premium. Or, you can choose to change it to Standard.
You can go to the Google Cloud Console and go to the virtual machine instance and inspect it and see which Service Tier has been selected.
But, is there a way to find out what the selected Service Tier is from a code running inside the virtual machine?
Looking at the existing predefined metadata keys, I cannot see one associated with the Network Service: Predefined metadata keys | Compute Engine Documentation | Google Cloud
There is no predefined metadata key to directly determine the Network Service Tier (Premium or Standard) from inside a Google Cloud VM. However, you can:
1. Fetch the external IP using the metadata server.
2. Compare the IP against Google's published IP ranges for Premium and Standard tiers.
This provides an indirect way to infer the Network Service Tier. you can also check the VM configuration via the Google Cloud Console or API.
Thanks a lot for the suggestion. Let me see if I can figure out how to do that.