diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2020-07-13 08:22:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-13 08:22:32 -0400 |
| commit | fa832c355922ff3e84f4caef855bd45a152c2ae2 (patch) | |
| tree | 4b87947a11c6b490605a86446cc21e5c0db2aa9e /docs/content | |
| parent | 597e72403db00bcef09e6e595efd4a213af73a1a (diff) | |
| parent | 2a30cb153fc6a1edecf571ba125b2daac12e404b (diff) | |
Merge pull request #891 from jen20/jen20/gcp-meta
Add gcp.Meta function, equivalent to aws.EC2Meta but for GCP
Diffstat (limited to 'docs/content')
| -rw-r--r-- | docs/content/functions/gcp.md | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/content/functions/gcp.md b/docs/content/functions/gcp.md new file mode 100644 index 00000000..be5acb9d --- /dev/null +++ b/docs/content/functions/gcp.md @@ -0,0 +1,50 @@ +--- +title: gcp functions +menu: + main: + parent: 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](https://cloud.google.com/compute/docs/storing-retrieving-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 + +```go +gcp.Meta key [default] +``` + +### Arguments + +| name | description | +|------|-------------| +| `key` | _(required)_ the metadata key to query | +| `default` | _(optional)_ the default value | + +### Examples + +```console +$ echo '{{gcp.Meta "id"}}' | gomplate +1334999446930701104 +``` +```console +$ echo '{{gcp.Meta "network-interfaces/0/ip"}}' | gomplate +10.128.0.23 +``` |
