terragrunt-action
terragrunt-action copied to clipboard
Add tg_output variable for JSON output
Description
This PR introduces a new output variable tg_output that contains the Terragrunt output in JSON format. This allows users to easily parse and extract specific values from the Terragrunt output using tools like jq within their GitHub Actions workflows.
Example usage:
- name: Extract test value
id: extract_test
run: |
echo '${{ steps.terragrunt.outputs.tg_output }}'
This feature is useful when you need Terragrunt output values for the next steps in your workflow. It eliminates the need to hardcode resource names in template files, making your workflow more dynamic and flexible.
In the AWS provider, there are several situations where this feature can be particularly useful
- When using CloudFront, it's often necessary to purge the cache after deploying changes. By extracting the CloudFront distribution's ARN using
tg_output, you can automate the cache purge process in your workflow. - In ECS deployments, it's common to wait for the ECS service to stabilize after an update. With
tg_output, you can easily access the service and cluster names, enabling you to implement a wait step in your workflow.
Release Notes (draft)
Added / Removed / Updated [X].
Added tg_output variable containing Terragrunt output in JSON format.
Migration Guide
N/A
@denis256 could you take a look on this? Output in json format would be very useful 😁
Will be helpful to add tests that will track JSON output generation
Will be helpful to add tests that will track JSON output generation
Disregard my last message, I got most of the tests working locally. However, the tests currently aren't setup for testing the outputs from the action. How were you envisioning that working, the only way I really see it working is by inspecting the github-action-logs that are written to /tmp currently.
What would need to be done for this to be merged?