Create gcp virtual machines through terraform

Hello community my name is Diego, I’m breaking my head trying to create virtual machines through code with python in google cloud platform but I have not found clear information in the documentation, researching I found that terraform can facilitate this, I would like how you can do it and if they have a tutorial to do this?

In the company where I work we have the following use case: We have 2 python scripts, we want that when a person registers to our service a virtual machine is automatically generated so that the scripts can work on it for that single client, in what way can i actually do this with terraform? Thank you in advance for your attention.

Terraform is a “desired state” configuration tool.

That means you will not be telling Terraform “make me a new VM”. Instead you will be updating a file or files that define what VMs should exist, and then telling Terraform “go update my GCP infrastructure to match the new definition”.

There is a getting started tutorial customised for GCP: GCP | Terraform | HashiCorp Developer

Try working through it, and ask further questions as needed.

If you do just want to create VMs from your Python script (instead of using a tool which handles the full lifecycle of creation, management and destruction) you are best of looking at Python libraries for talking the GCP, as Terraform is probably not the best option.