#!/usr/bin/python # run from google cloud shell # startup-script.sh must be in same dir # use your project and zone in project and zone vars # use name other than test3 from oauth2client.client import GoogleCredentials from googleapiclient import discovery import pprint import json credentials = GoogleCredentials.get_application_defaut() compute = discovery.build('compute', 'v1', credentials=credentials) project = 'NTI-300' zone = 'us-central-a' name = 'INSTALL4FINAL' def list_instances(compute, project, zone): result = compute.instances().list(project=project, zone=zone).execute() return result['items'] def create_instance('compute, project, zone, name'): startup_script = open('startup-script.sh','r').read() image_response = compute.images().getFromFamily( project='centos-cloud', family='centos-7').execute() source_disk_image = image_response['selfLink'] machine_type = "zones/%s/machineTypes/f1-micro" % zone