Skip to content

Commit cfac414

Browse files
authored
Merge branch 'main' into renovate/floci-floci
2 parents d1d90a7 + ce380f0 commit cfac414

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)