summaryrefslogtreecommitdiff
path: root/docs-src
diff options
context:
space:
mode:
authorJames Nugent <james@jen20.com>2020-07-10 12:19:04 -0500
committerJames Nugent <james@jen20.com>2020-07-12 11:50:58 -0500
commit2a30cb153fc6a1edecf571ba125b2daac12e404b (patch)
tree131d69345c65e17fd0cc0ebd6d8580a20c9a504e /docs-src
parent65936317408b1c865487c669d44ba8ad611b0fbc (diff)
Add gcp.Meta function, equivalent to aws.EC2Meta
This commit adds a new namespace and function: `gcp.Meta`, which can be used to look up values from the GCP Instance Metadata service. An example usage: ``` echo '{{ gcp.Meta "id" }}' | gomplate ``` This also supports paths, so usage like this works: ``` echo '{{ gcp.Meta "network-interfaces/0/ip" }}' | gomplate ```
Diffstat (limited to 'docs-src')
-rw-r--r--docs-src/content/functions/gcp.yml36
1 files changed, 36 insertions, 0 deletions
diff --git a/docs-src/content/functions/gcp.yml b/docs-src/content/functions/gcp.yml
new file mode 100644
index 00000000..036b1ecb
--- /dev/null
+++ b/docs-src/content/functions/gcp.yml
@@ -0,0 +1,36 @@
+ns: gcp
+preamble: |
+ 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. |
+funcs:
+ - name: gcp.Meta
+ description: |
+ 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.
+ pipeline: false
+ arguments:
+ - name: key
+ required: true
+ description: the metadata key to query
+ - name: default
+ required: false
+ description: the default value
+ examples:
+ - |
+ $ echo '{{gcp.Meta "id"}}' | gomplate
+ 1334999446930701104
+ - |
+ $ echo '{{gcp.Meta "network-interfaces/0/ip"}}' | gomplate
+ 10.128.0.23