How can I get the current running instanceId, and it's zone in the running Python application.
In Go and Java it's done in the following way, what is the equivilant in Python?
Go,
import metadata "cloud.google.com/go/compute/metadata"
func main(){
println(metadata.InstanceID))
}
Java
String instanceId = com.google.cloud.MetadataConfig.getInstanceId()
I found an easy solution:
requests.get("http://metadata/computeMetadata/v1/instance/id",
headers={'Metadata-Flavor': 'Google'}).text