-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gomplate
templating engine to Atmos stack manifests. Update docs
#578
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # examples/quick-start/stacks/orgs/acme/_defaults.yaml # go.mod # go.sum
osterman
approved these changes
Apr 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what
gomplate
templating engine to Atmos stack manifestswhy
Allow using the rich collection of the Gomplate Functions in Atmos stack manifest
NOTE: The Gomplate Datasources, including configuring the datasources in Atmos stack manifests and using Inheritance for datasources, will be added in the follow up PR
Description
Configuration
Templating in Atmos stack manifests is configured in the
atmos.yaml
CLI config file in thetemplates
section:templates.settings.enabled
- a boolean flag to enable/disable the processing ofGo
templates in Atmos stack manifests. If setto
false
, Atmos will not processGo
templates in stack manifeststemplates.settings.sprig.enabled
- a boolean flag to enable/disable the Sprig Functionsin Atmos stack manifests
templates.settings.gomplate.enabled
- a boolean flag to enable/disable the Gomplate Functionsin Atmos stack manifests
Atmos sections supporting
Go
templatesYou can use
Go
templates in the following Atmos sections to refer to values in the same or other sections:vars
settings
env
metadata
providers
overrides
backend
backend_type
For example, let's say we have the following component configuration using
Go
templates:When executing Atmos commands like
atmos describe component
andatmos terraform plan/apply
, Atmos processes all the template tokens in the manifest and generates the final configuration for the component in the stack:Use-cases
While
Go
templates in Atmos stack manifests offer great flexibility for various use-cases, one of the obvious use-cases is to add a standard set of tags to all the resources in the infrastructure.For example, by adding this configuration to the
stacks/orgs/acme/_defaults.yaml
Org-level stack manifest:The tags will be processed and automatically added to all the resources provisioned in the infrastructure.
Excluding templates from processing by Atmos
If you need to provide
Go
templates to external systems (e.g. ArgoCD or Datadog) verbatim and prevent Atmos from processing the templates, use double curly braces + backtick + double curly braces instead of just double curly braces:For example:
When Atmos processes the templates in the manifest shown above, it renders them as raw strings allowing sending the templates to the external system for processing:
The
printf
template function is also supported and can be used instead of double curly braces + backtick + double curly braces.The following examples produce the same result:
References