Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch Google Compute instances programmatically?

In the AWS SDK, EC2 instances can be launched programmatically via the AmazonEC2Client. Does GCP in general or Compute Engine specifically just offer the CLI-based gcloud command for the equivalent operation? Or can GCE instances be controlled from Java/Python/Go/etc as well? Which SDK exists for those languages and where are the examples & docs for this?

I am looking for the equivalent of this in the GCP world:

client = new AmazonEC2Client(credentials);
client.runInstances(new RunInstancesRequest())
like image 367
Ingo Avatar asked Mar 13 '23 02:03

Ingo


1 Answers

You're looking for the Google Cloud Client Libraries, of which gcloud-java is the Java implementation. There are also Client Libraries in Go, Node.js, Python, and Ruby.

Under the covers everything in Google Cloud is available via an API, so even if there isn't a client library for what you're trying to accomplish, it can be done programmatically by calling the API directly.

The documentation on launching instances has an API tab that shows both Client Library and REST API examples.

like image 76
dimo414 Avatar answered Mar 24 '23 21:03

dimo414