These samples demonstrate usage of the google-cloud-compute library to interact with the Google Compute Engine API.
-
If you haven't already, set up a Python Development Environment by following the python setup guide and create a project.
-
Create a service account with the 'Editor' permissions by following these instructions.
-
Download a JSON key to use to authenticate your script.
-
Configure your local environment to use the acquired key.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
Create a new virtual environment and install the required libraries.
virtualenv --python python3 name-of-your-virtualenv
source name-of-your-virtualenv/bin/activate
pip install -r requirements.txt
Run the quickstart script, it will create and destroy a n1-standard-1
type machine in the europe-central2-b
zone.
python quickstart.py