Skip to content

Commit ce380f0

Browse files
ostermanclaudeaknysh
authored
docs: add succinct Gomplate datasource example (#2866)
* docs: add succinct Gomplate datasource example Consolidates two duplicate open PRs (#2748, #2651) that both attempted to answer issue #2650 with a much longer AWS-specific example. Uses Erik's succinct rewrite from his review comment on #2748 instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs: link !include, fix describe command in datasource example Address CodeRabbit review feedback on #2866: the example command was missing --query '.vars' to match the shown output. Also link !include to its function docs per review feedback. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
1 parent 5c24ea2 commit ce380f0

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

website/docs/templates/datasources.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,62 @@ components:
246246
```
247247
</File>
248248
249+
## Example: Using a Gomplate Datasource
250+
251+
<PillBox>Advanced</PillBox>
252+
253+
Gomplate datasources make external data available inside template expressions.
254+
255+
> **Note:** Atmos [`!include`](/functions/yaml/include) functions and Gomplate datasources both load external data, but they serve different purposes. [`!include`](/functions/yaml/include) imports data directly into the Atmos configuration as part of YAML processing. Gomplate datasources expose data within template expressions, where it can be transformed, filtered, combined, or otherwise manipulated using Gomplate functions before being assigned to a value.
256+
257+
Configure a YAML datasource:
258+
259+
<File title="atmos.yaml">
260+
261+
```yaml
262+
settings:
263+
templates:
264+
settings:
265+
gomplate:
266+
datasources:
267+
config:
268+
url: "file://config.yaml"
269+
```
270+
271+
</File>
272+
273+
Use the datasource in template expressions:
274+
275+
<File title="stack.yaml">
276+
277+
```yaml
278+
components:
279+
terraform:
280+
app:
281+
vars:
282+
account_id: '{{ (datasource "config").account_id }}'
283+
region: '{{ (datasource "config").region }}'
284+
```
285+
286+
</File>
287+
288+
Render the final configuration:
289+
290+
<Terminal>
291+
292+
```bash
293+
atmos describe component app -s dev --query '.vars'
294+
```
295+
296+
</Terminal>
297+
298+
Example output:
299+
300+
```yaml
301+
account_id: "111111111111"
302+
region: "eu-west-2"
303+
```
304+
249305
## Using templates in the URLs of `datasources`
250306

251307
<PillBox>Advanced</PillBox>

0 commit comments

Comments
 (0)