github.com/hairyhenderson/gomplate/v4@v4.0.0-pre-2.0.20240520121557-362f058f0c93/docs/content/functions/gcp.md (about) 1 --- 2 title: gcp functions 3 menu: 4 main: 5 parent: functions 6 --- 7 8 The functions in the `gcp` namespace interface with various Google Cloud Platform 9 APIs to make it possible for a template to render differently based on the GCP 10 environment and metadata. 11 12 ### Configuring GCP 13 14 A number of environment variables can be used to control how gomplate communicates 15 with GCP APIs. 16 17 | Environment Variable | Description | 18 | -------------------- | ----------- | 19 | `GCP_META_ENDPOINT` | _(Default `http://metadata.google.internal`)_ Sets the base address of the instance metadata service. | 20 | `GCP_TIMEOUT` | _(Default `500`)_ Adjusts timeout for API requests, in milliseconds. | 21 22 ## `gcp.Meta` 23 24 Queries GCP [Instance Metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata) for information. 25 26 For times when running outside GCP, or when the metadata API can't be reached, a `default` value can be provided. 27 28 _Added in gomplate [v3.8.0](https://github.com/hairyhenderson/gomplate/releases/tag/v3.8.0)_ 29 ### Usage 30 31 ``` 32 gcp.Meta key [default] 33 ``` 34 35 ### Arguments 36 37 | name | description | 38 |------|-------------| 39 | `key` | _(required)_ the metadata key to query | 40 | `default` | _(optional)_ the default value | 41 42 ### Examples 43 44 ```console 45 $ echo '{{gcp.Meta "id"}}' | gomplate 46 1334999446930701104 47 ``` 48 ```console 49 $ echo '{{gcp.Meta "network-interfaces/0/ip"}}' | gomplate 50 10.128.0.23 51 ```