Script icon
TerraformCLI icon
SlackIncomingWebhook icon
Set icon

Provision Google Cloud VMs with Terraform, IPAM, and Slack Notifications

Provision Google Cloud VMs with Terraform and Kestra. Generate standardized hostnames, reserve IPs from IPAM, apply with Terraform, and notify Slack.

Categories
Infrastructure

Provision Google Cloud Compute Engine virtual machines on demand with an Infrastructure as Code workflow that turns a self-service form into a fully governed VM. This blueprint generates a standardized hostname, reserves an IP address from an external IPAM, applies a Terraform configuration to create the instance, and posts the results to Slack. It solves the messy reality of cloud VM provisioning, where naming drifts, IP conflicts happen, and nobody knows a machine exists until someone asks.

How it works

  1. generateCustomHostname runs an io.kestra.plugin.scripts.python.Script task that builds a hostname from the cloud provider, environment, OS, and VM type inputs, plus a numeric index pulled from Kestra KV (kv('getVMIndex')).
  2. getIPAddress runs another io.kestra.plugin.scripts.python.Script task that calls your external IPAM API to reserve the first free IP in the selected subnet.
  3. createVM uses io.kestra.plugin.terraform.cli.TerraformCLI with inline main.tf to run terraform init, plan, and apply -auto-approve, creating a google_compute_instance and writing the external IP to an output file.
  4. notifyChannel sends an io.kestra.plugin.slack.notifications.SlackIncomingWebhook message with the hostname, external IP, default user, and full machine configuration.
  5. incrementindex uses io.kestra.plugin.core.kv.Set to bump the VM index so the next provisioning run gets a unique name.

What you get

  • Collision-free, standardized VM hostnames driven by KV-backed indexing.
  • IPAM-reserved IPs so addresses are governed centrally, not guessed.
  • Declarative Terraform provisioning with init, plan, and apply in one task.
  • A Slack message summarizing every new VM with its IP and configuration.
  • The external IP surfaced as a flow output for downstream use.

Who it's for

  • Platform and cloud infrastructure engineers offering self-service VMs.
  • DevOps teams standardizing Google Cloud provisioning.
  • Operations teams that need network governance and visibility on new machines.

Why orchestrate this with Kestra

Terraform applies infrastructure, but it has no scheduler, no event triggers, and no built-in way to chain a hostname generator, an IPAM lookup, and a Slack notification around an apply. Kestra wraps the apply in a declarative YAML flow with retries, full execution lineage, and an input form that non-experts can drive. The KV store keeps stateful naming between runs, something a bare terraform apply cannot do on its own.

Prerequisites

  • A Kestra instance with the Terraform, GCP, Slack, Python script, and core plugins.
  • A Google Cloud project with Compute Engine enabled and an existing network and subnet.
  • An external IPAM endpoint reachable from Kestra (configured via the ipamAddress KV).

Secrets

  • GCP_SVC_ACCOUNT: service account JSON used by Terraform as GOOGLE_APPLICATION_CREDENTIALS.
  • SSH_PUB_KEY: public key injected into the VM metadata.
  • SLACK_WEBHOOK (in the system namespace): incoming webhook URL for notifications.
  • SSH_VM_USER: default user reported in the Slack message.

Quick start

  1. Add the secrets above to your Kestra instance.
  2. Set the ipamAddress KV (and optionally getVMIndex) for your environment.
  3. Adjust the main.tf inputs and select lists to match your project, networks, and machine types.
  4. Execute the flow, fill in the form, and watch the VM get created and announced in Slack.

How to extend

  • Add a destroy flow that runs terraform destroy for teardown.
  • Swap the inline IPAM call for your own provider (Infoblox, NetBox, phpIPAM).
  • Branch the Terraform configuration to support the AWS and Azure options already in the form.
  • Add approval or cost-estimation steps before apply.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.