I would like to automatically create client instances and run client Python script on them. I can create a client instance as follows:
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('compute', 'beta', credentials=credentials)
project = 'my-project'
zone = 'us-central1-a'
instance_body = {
"name": "my-instance-name",
"sourceMachineImage": "projects/my-project/global/machineImages/my-image",
}
request = service.instances().insert(project=project, zone=zone, body=instance_body)
response = request.execute()
However, the response object does not seem to contain any authentication details for the new instance. Since I have the name of the instance, I can obtain its internal IP address from the list of instances, but that is not enough to connect to it. So how can run my client Python script on the newly created instance?