Skip to content
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 tg_output variable for JSON output #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iisyos
Copy link

@iisyos iisyos commented Apr 6, 2024

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

@robcio-ops
Copy link

@denis256 could you take a look on this? Output in json format would be very useful 😁

@denis256
Copy link
Member

Will be helpful to add tests that will track JSON output generation

@zackpollard
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants