gcp functions

The functions in the gcp namespace interface with various Google Cloud Platform APIs to make it possible for a template to render differently based on the GCP environment and metadata.

Configuring GCP

A number of environment variables can be used to control how gomplate communicates with GCP APIs.

Environment Variable Description
GCP_META_ENDPOINT (Default http://metadata.google.internal) Sets the base address of the instance metadata service.
GCP_TIMEOUT (Default 500) Adjusts timeout for API requests, in milliseconds.


Queries GCP Instance Metadata for information.

For times when running outside GCP, or when the metadata API can’t be reached, a default value can be provided.

Added in gomplate v3.8.0


gcp.Meta key [default]


name description
key (required) the metadata key to query
default (optional) the default value


$ echo '{{gcp.Meta "id"}}' | gomplate
$ echo '{{gcp.Meta "network-interfaces/0/ip"}}' | gomplate