-
-
Notifications
You must be signed in to change notification settings - Fork 961
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 getTerragruntSource helper function #1575
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The code changes look good overall, but could you please:
- Describe the use case for this
- Update the docs
Thanks!
Hi brikis98, thanks for reviewing! Regarding your questions, I added the new function to the list of internal functions in the documentation and provided some information on what the function will return. I'm not sure what the use case for this might be. I'll ask in the original issue for more clarification. |
config/config_helpers.go
Outdated
@@ -115,6 +115,7 @@ func CreateTerragruntEvalContext( | |||
"get_terraform_commands_that_need_input": wrapStaticValueToStringSliceAsFuncImpl(TERRAFORM_COMMANDS_NEED_INPUT), | |||
"get_terraform_commands_that_need_parallelism": wrapStaticValueToStringSliceAsFuncImpl(TERRAFORM_COMMANDS_NEED_PARALLELISM), | |||
"sops_decrypt_file": wrapStringSliceToStringAsFuncImpl(sopsDecryptFile, extensions.Include, terragruntOptions), | |||
"get_terragrunt_source": wrapVoidToStringAsFuncImpl(getTerragruntSource, extensions.Include, terragruntOptions), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should rename this to get_terragrunt_source_cli_flag
to make clear that this only returns values passed through with --terragrunt-source
?
|
||
## get\_terragrunt\_source | ||
|
||
`get_terragrunt_source()` returns the location of the Terraform files. This location can be provided via CLI `--terragrunt-source`, an environment variable `TERRAGRUNT_SOURCE` or in the `terragrunt.hcl` file. Calling this function will return the value of that field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`get_terragrunt_source()` returns the location of the Terraform files. This location can be provided via CLI `--terragrunt-source`, an environment variable `TERRAGRUNT_SOURCE` or in the `terragrunt.hcl` file. Calling this function will return the value of that field. | |
`get_terragrunt_source()` returns the value passed in via the CLI `--terragrunt-source` or an environment variable `TERRAGRUNT_SOURCE`. Note that this will return an empty string when either of those values are not provided. | |
This is useful for constructing before and after hooks, or TF flags that only apply to local development (e.g., setting up debug flags, or adjusting the `iam_role` parameter). |
The main use case for this is to adjust the terragrunt configuration depending on whether its local development or not (
|
Roger, thx for the explanation! May be worth adding to the docs! |
Added use cases to the docs for Let me know if there's anything else I can add. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates LGTM! Will kick off the build momentarily.
Build passed, so going to merge this in! Thanks for your contribution! |
* Fix dead link in multiple aws accounts docs (gruntwork-io#1563) * Fix dead link in multiple aws accounts docs The link to AWS docs is now 404. The corrected link seems to most closely resemble the intended target. Other options to consider: https://aws.amazon.com/organizations/getting-started/best-practices/ https://docs.aws.amazon.com/controltower/latest/userguide/aws-multi-account-landing-zone.html * Link to AWS best practices for multi account docs * Whitespace removal (gruntwork-io#1573) * Fix empty outputs (gruntwork-io#1568) If stack run finished without errors, `summarizePlanAllErrors()` receives empty buffer and outputs empty line. This change ensures that only non-empty outputs are getting logged. Related: gruntwork-io#1541 * doc: contributing: fix broken link to circleci (gruntwork-io#1580) * Bump AWS SDK to version v1.37.7 to support AWS SSO (gruntwork-io#1537) * Add TargetPrefix as config input to access bucket logging (gruntwork-io#1507) * adding target-prefix ro access bucket logging * Updating test & example ! Note that this needs the terratest PR (gruntwork-io/terratest#767) to be merged in to work & be tested. * Updating Terratest dependency * testing for target prefix * Updating docs * Renaming folder * Updating to Debugf * Adding default value * WIP - parsing for TFstatelogs * Updating logic & docs * Adding a new test for default TargetPrefix in remote backend config * Introduce validate-inputs, which can be used to check for variable alignment (gruntwork-io#1572) * Introduce terragrunt-input-info, which can be used to check for variable alignment * Apply suggestions from code review Co-authored-by: Zack Proser <zackproser@gmail.com> * Tidy go modules * Renamed input-info to validate-inputs * Switch missing required vars to errors * Handle -var and -var-file args * Update cli/validate_inputs.go Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com> * Make sure to check for dynamically passed in CLI args * Fix build * Handle automatically loaded var files * Remove plan args check * Clarify difference between getTerraformInputNamesFromVarFiles and getTerraformInputNamesFromCLIArgs * Address PR nit to move example in docs Co-authored-by: Zack Proser <zackproser@gmail.com> Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com> * Use go1.16 to build arm64 binaries (gruntwork-io#1585) * Bump creack/pty to 1.1.11 (gruntwork-io#1582) Co-authored-by: Andy Bohne <andrew.bohne@ring.com> * Add ability to specify working directory of hooks (gruntwork-io#1588) * Add ability to specify working directory of hooks * Fix build * Support dynamodb_endpoint attribute of S3 backend (gruntwork-io#1586) * Clarify non-interactive will not include external dependencies (gruntwork-io#1593) * add getTerragruntSource helper function (gruntwork-io#1575) * add getTerragruntSource helper function * update docs * update docs and tests for get_terragrunt_source_cli_flag() function * add use cases for get_terragrunt_source_cli_flag * Recursively extract forcedgetters until there are none (gruntwork-io#1594) * Remove all usage of get-plugins=false which is removed in 0.15.0 (gruntwork-io#1618) * Fix validate-inputs to support null defaults (gruntwork-io#1613) * Clarify context of find_in_parent_folders (gruntwork-io#1623) Co-authored-by: Paul <1727604+paulvandenburg@users.noreply.github.com> Co-authored-by: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> Co-authored-by: amnk <amnk@users.noreply.github.com> Co-authored-by: Marco Molteni <51477941+marco-m-pix4d@users.noreply.github.com> Co-authored-by: David Wooldridge <zombie@zombix.org> Co-authored-by: Ina Stoyanova <ina@gruntwork.io> Co-authored-by: Zack Proser <zackproser@gmail.com> Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com> Co-authored-by: Andy Bohne <abohne@users.noreply.github.com> Co-authored-by: Andy Bohne <andrew.bohne@ring.com> Co-authored-by: Alexey Remizov <alexey@remizov.org> Co-authored-by: Syed Hussain <suhussai@ualberta.ca> Co-authored-by: David Alger <davidmalger@gmail.com>
No description provided.