---
title: "Deploy development virtual machines on Google Cloud"
description: "Easily deploy development VMs on Google Cloud using Terraform. Choose from multiple OS options with automated setup for seamless integration."
url: "https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/instance-provisioning/google-cloud-instance-provisioning/index.html"
---
This page details the Terraform configuration for deploying development virtual machines (VMs) on Google Cloud Platform (GCP) with multiple operating system options and automated Netprobe deployment. This environment creates development VMs on GCP with:

- Multiple OS choices (Ubuntu 22.04/24.04 LTS, RHEL 8/9)
- Ansible deployment automation
- SSH key authentication
- Configurable VM specifications
- Resource labeling for organization

## Template files

The environment contains the following Terraform configuration files:

- `main.tf` — the main configuration that provisions VM instances and triggers the Ansible deployment
- `variables.tf` — variable definitions for all configurable parameters
- `outputs.tf` — output definitions for deployment information
- `providers.tf` — GCP provider configuration
- `versions.tf` — Terraform and provider version constraints
- `terraform.tfvars.[os].example` — configuration file for your operating system

## Prerequisites

1. [Terraform](https://www.terraform.io/downloads) version 1.0 or higher installed

2. [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) version 400.0.0 or higher installed

3. [GCP authentication](#authentication-overview) configured

4. GCP project with required APIs enabled:

   ```bash
   # Enable required APIs
   gcloud services enable compute.googleapis.com
   gcloud services enable oslogin.googleapis.com
   
   # Set default project
   gcloud config set project YOUR_PROJECT_ID
   ```

5. SSH key pair for VM access

   ```bash
   # Generate SSH key pair if not already available
   ssh-keygen -t rsa -b 4096 -f ../../../../../resources/id_rsa
   ```

6. IAM permissions, where the user or service account must have:
   - Compute Instance Admin
   - Compute Security Admin
   - Service Account User

## Deployment setup

1. Copy the example configuration.

   ```bash
   # For Ubuntu 22.04 (default)
   cp terraform.tfvars.example terraform.tfvars
   
   # For Ubuntu 24.04
   cp terraform.tfvars.ubuntu24.example terraform.tfvars
   
   # For RHEL 8
   cp terraform.tfvars.rhel8.example terraform.tfvars
   
   # For RHEL 9
   cp terraform.tfvars.rhel9.example terraform.tfvars
   ```

2. Update `terraform.tfvars` [configuration file](#configuration-files) with your Google Cloud settings.

   ```bash
   nano terraform.tfvars
   ```

3. [Deploy](#terraform-commands) the infrastructure.

   ```bash
   terraform init
   terraform plan
   terraform apply
   ```

## Authentication overview

This deployment requires two types of authentication:

1. Terraform authentication (infrastructure creation) to allow Terraform to create virtual machines, networks, and cloud resources. For Google Cloud, you need to configure `gcloud auth` or the service account credentials.

   - User account — makes use of your personal Google account for authentication.

      ```bash
      gcloud auth login
      gcloud auth application-default login
      ```

   -Service account — makes use of a service account for automated deployments.

      ```bash
      export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
      ```

   - Workload Identity (GKE/Cloud Build) — makes use of a workload identity for deployments from GCP services.

2. Application authentication (cloud storage access) to allow applications running on virtual machines to download the deployment resources from the respective cloud storage. This is configured in the `netprobe.yml` file for each environment. Refer to [Google Cloud Platform authentication](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/ansible-configuration/index.html#google-cloud-platform-gcp) for detailed authentication configuration.

## Configuration files

Select the appropriate configuration file for your operating system:

| Operating system | Configuration file |
|-------|-------|
| Ubuntu 22.04 LTS (default) | `terraform.tfvars.example` |
| Ubuntu 24.04 LTS | `terraform.tfvars.ubuntu24.example` |
| RHEL 8 | `terraform.tfvars.rhel8.example` |
| RHEL 9 | `terraform.tfvars.rhel9.example` |

In the selected configuration file, configure the parameters outlined below.

### GCP account configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `gcp_project_id` | GCP project ID for deployment |  | Yes |
| `gcp_region` | GCP region for deployment | "us-central1" | Yes |
| `gcp_zone_id` | Zone suffix within the region | "a" | Yes |

### GCP service account configuration

The service account must be created by the user before deployment. This service account will be attached to the VM instances during creation.

Example service account creation:

```bash
# Create the service account for VM instances
gcloud iam service-accounts create dev-instance-sa \
    --display-name="Development Instance Service Account" \
    --project=your-project-id
```

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `gcp_service_account_email` | Email of existing service account to attach to instances |  | Yes |
| `gcp_service_account_scopes` | List of access scopes for the service account | ["cloud-platform"] | Yes |

### Deployment configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `deployment_count` | Number of identical VM deployments to create | 1 | Yes |
| `labels` | Resource labels to assign to all created resources | {} | No |

### Network configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `network_name` | VPC network name | "default" | Yes |
| `subnetwork_name` | Subnet name | "default" | Yes |

### Virtual machine configuration

Virtual machine configurations are based on the [Netprobe system requirements](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/netprobe/installation/quickstart-linux-and-other-platforms/index.html#system-requirements). The default machine type and boot OS disk type and size also follow the Netprobe requirements.

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `vm_name` | Base name for VM instances | "vm-template" | Yes |
| `vm_type` | GCP machine type | "n2-standard-2" | Yes |
| `vm_image_family` | VM boot image family | "ubuntu-2204-lts" | Yes |
| `vm_image_project` | GCP project containing the VM image | "ubuntu-os-cloud" | Yes |
| `vm_disk_size` | VM boot disk size in GB | 50 | Yes |
| `vm_disk_type` | VM boot disk type | "pd-ssd" | Yes |
| `vm_status` | Desired VM status | "RUNNING" | Yes |

### SSH access configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `ssh_user` | SSH username for VM access | "netprobe_user" | Yes |
| `ssh_public_key_path` | Path to SSH public key file | "../../../../../resources/id_rsa.pub" | Yes |

### Ansible deployment configuration

| Parameter | Description | Default | Required |
|-------|-------|-------|-------|
| `ansible_playbook_path` | Path to Ansible playbook | "../../../../ansible/netprobe.yml" | Yes |
| `ansible_operation` | [Deployment operation](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/ansible-configuration/index.html#ansible-supported-operations) | "install" | Yes |
| `additional_args` | Additional Ansible playbook arguments | "" | No |

## Resources created

The following GCP infrastructure resources will be created:

| Resource | Description |
|-----------|-------------|
| Compute instance | VM with selected OS and automatic image detection |
| Ansible deployment | Automated Netprobe service installation |

## Outputs

The following outputs will be available after deployment:

| Output | Description |
|--------|-------------|
| `external_ip` | External IP address of the compute instance |
| `internal_ip` | Internal IP address of the compute instance |
| `instance_name` | Name of the compute instance |
| `instance_zone` | Zone where the instance is deployed |
| `operating_system` | Operating system version selected |
| `ssh_user` | SSH username for the operating system |
| `deployment_summary` | Summary of all deployed resources |

## Ansible integration

Ansible playbooks are automatically executed after the creation of the virtual machine. These are used to:

- Configure the Netprobe service.
- Set up monitoring connections to the Gateway.
- Apply environment-specific settings.
- Install the required dependencies.

## Troubleshooting

You can run the given commands if you encounter the following issues:

| Issue type | Command |
|------------|---------|
| Authentication issues | ```bash
# Check current GCP identity
gcloud auth list
# Check application default credentials
gcloud auth application-default print-access-token
# Re-authenticate
gcloud auth login
gcloud auth application-default login
# Check project configuration
gcloud config list
``` |
| Project and API issues | ```bash
# List available projects
gcloud projects list
# Set project
gcloud config set project YOUR_PROJECT_ID
# Check enabled APIs
gcloud services list --enabled
# Enable required APIs
gcloud services enable compute.googleapis.com
``` |
| Instance issues | ```bash
# Check instance status
gcloud compute instances list
# Get instance details
gcloud compute instances describe INSTANCE_NAME --zone=ZONE
# Check via Terraform
terraform show
terraform state list
``` |
| Image issues | ```bash
# List available Ubuntu images
gcloud compute images list --project=ubuntu-os-cloud --filter="family:ubuntu-minimal-2204-lts"
# List available RHEL images
gcloud compute images list --project=rhel-cloud --filter="family:rhel-9"
``` |
| SSH connection issues | ```bash
# Check firewall rules
gcloud compute firewall-rules list
# Test SSH connection
ssh -i ../../../../../resources/id_rsa netprobe_user@<instance-ip>
# Use gcloud SSH (alternative)
gcloud compute ssh INSTANCE_NAME --zone=ZONE
``` |
| Ansible deployment issues | ```bash
# Check Ansible logs in Terraform output
terraform apply -auto-approve
# Manual Ansible execution
ansible-playbook -i <instance-ip>, ../../../../ansible/netprobe.yml \
--private-key ../../../../../resources/id_rsa \
--user netprobe_user \
--extra-vars "operation=install"
``` |

## Terraform commands

Run the following Terraform commands to deploy the infrastructure.

| Command | Command |
|-----------|-------------|
| Initialize Terraform | ```bash
terraform init
``` |
| Plan the deployment | ```bash
terraform plan -var-file="terraform.tfvars"
``` |
| Apply the deployment | ```bash
terraform apply -var-file="terraform.tfvars"
``` |
| Show the deployment options | ```bash
terraform output
``` |
| Destroy the deployment | ```bash
terraform destroy -var-file="terraform.tfvars"
``` |

## Netprobe Configuration

The `netprobe.yml` file contains Ansible configuration for Netprobe deployment. For general configuration structure and available parameters, refer to [Ansible configuration](https://docs.itrsgroup.com/docs/geneos/7.11.0/collection/cloud-native-deployments/deploying-via-terraform/ansible-configuration/index.html).

Update the following environment-specific settings in `netprobe.yml` file for your GCP development environment:

### SSH configuration

```yaml
# SSH connection configuration (required)
ansible_ssh_private_key_file: "../../../../resources/id_rsa"
ansible_ssh_common_args: "-o ControlMaster=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
```

### Bootstrap configuration

```yaml
# Set to false for dev environments (minimal bootstrap)
perform_bootstrap: false

# GCP Cloud Storage library installation if perform_bootstrap is true
additional_bootstrap: "{{ python_path }} -m pip install --upgrade google-cloud-storage"
```

### Cloud provider configuration

```yaml
resources:
  # Google Cloud Storage configuration
  source:
    gcp:
      auth_kind: "machineaccount"
      # credential: "service-account@project-id.iam.gserviceaccount.com"  # Optional override
  # Cloud storage container
  container: geneos
  # Resource paths
  path: netprobe.tar.gz
  setupfile:
    path: netprobe.setup_template.xml
```

### Gateway connection

```yaml
env_vars:
  # Gateway information (configure for your setup)
  GATEWAY_HOST: "0.0.0.0"
  GATEWAY_PORT: "7039"
```

### Netprobe connection

```yaml
env_vars:
  # Netprobe information
  SERVICE_PARAM: "-port 7036 -setup {{ workspace_dir }}/{{ resources.setupfile.path | basename }}"
```

