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.

gcp.Meta

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.

Usage

gcp.Meta key [default]

Arguments

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

Examples

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