Description

June 10, 2026 ยท View on GitHub

This module creates a VM that acts as a login node to test and submit Google Cloud Batch jobs. It is intended to be used along with the batch-job-template module.

This login node:

  • Uses the same VM settings as the first provided batch-job-template, such as image, machine type, etc...
  • Runs the same startup-script as the first provided batch-job-template.
  • Has the same mounted file systems as the provided batch-job-template.
  • Contains a folder with job templates generated by batch-job-template modules.

Since the login node has the same mounted storage and is a homogeneous machine to the Google Cloud Batch compute VMs, it can be used to inspect shared file systems and test installed software before submitting a Google Cloud Batch job.

Note on Testing: The login node is intended for environment verification (checking paths, storage mounts, and single-node execution). It is a single VM instance and does not support testing multi-node MPI communication. To test multi-node behavior, you must submit the Batch job to the service.

Example

- id: batch-job
  source: modules/scheduler/batch-job-template
  ...

- id: batch-login
  source: modules/scheduler/batch-login-node
  use: [batch-job]
  outputs: [instructions]

Authentication

To submit jobs from the login node, the service account attached to the VM needs the Batch Job Administrator role. In most cases this service account will be the Compute Engine default service account and will not be granted this role by default.

You can grant this role either by adding the Batch Job Administrator role to the service account in the IAM page in the Google Cloud Console, or by running the following command line:

gcloud projects add-iam-policy-binding <project ID> \
  --member=serviceAccount:<service account email> \
  --role=roles/batch.jobsAdmin

gcloud Batch Access

Until the Google Cloud Batch API is generally available (GA), it may not be available in all versions of the gcloud cli. You can test if the Google Cloud Batch commands are available by running gcloud [alpha|beta|] batch -h. If the Google Cloud Batch cli is not available it can generally be mitigated by either updating gcloud by running gcloud components update, or using an image that contains a more recent version of gcloud.

License

Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Requirements

NameVersion
terraform>= 1.12.2
google>= 3.83

Providers

NameVersion
google>= 3.83

Modules

NameSourceVersion
login_startup_script../../scripts/startup-scriptn/a

Resources

NameType
google_compute_instance_from_template.batch_loginresource
google_compute_instance_template.batch_instance_templatedata source

Inputs

NameDescriptionTypeDefaultRequired
batch_job_directoryThe path of the directory on the login node in which to place the Google Cloud Batch job templatestring"/home/batch-jobs"no
deployment_nameName of the deployment, also used for the job_idstringn/ayes
enable_osloginEnable or Disable OS Login with "ENABLE" or "DISABLE". Set to "INHERIT" to inherit project OS Login setting.string"ENABLE"no
gcloud_versionThe version of the gcloud cli being used. Used for output instructions.
Valid inputs are \"alpha\", \"beta\" and "" (empty string for default
version). Typically supplied by a batch-job-template module. If multiple
batch-job-template modules supply the gcloud_version, only the first will be used.
string""no
instance_templateLogin VM instance template self-link. Typically supplied by a
batch-job-template module. If multiple batch-job-template modules supply the
instance_template, the first will be used.
stringn/ayes
job_dataList of jobs and supporting data for each, typically provided via "use" from the batch-job-template module.
list(object({
template_contents = string,
filename = string,
id = string
}))
n/ayes
job_filenameDeprecated (use job_data): The filename of the generated job template file. Typically supplied by a batch-job-template module.stringnullno
job_idDeprecated (use job_data): The ID for the Google Cloud Batch job. Typically supplied by a batch-job-template module for use in the output instructions.stringnullno
job_template_contentsDeprecated (use job_data): The contents of the Google Cloud Batch job template. Typically supplied by a batch-job-template module.stringnullno
labelsLabels to add to the login node. Key-value pairsmap(string)n/ayes
network_storageAn array of network attached storage mounts to be configured. Typically supplied by a batch-job-template module.
list(object({
server_ip = string
remote_mount = string
local_mount = string
fs_type = string
mount_options = string
client_install_runner = map(string)
mount_runner = map(string)
}))
[]no
project_idProject in which the HPC deployment will be createdstringn/ayes
regionThe region in which to create the login nodestringn/ayes
startup_scriptStartup script run before Google Cloud Batch job starts. Typically supplied by a batch-job-template module.stringnullno
zoneThe zone in which to create the login nodestringn/ayes

Outputs

NameDescription
instructionsInstructions for accessing the login node and submitting Google Cloud Batch jobs
login_node_nameName of the created VM