terragrunt-action icon indicating copy to clipboard operation
terragrunt-action copied to clipboard

Add tg_output variable for JSON output

Open iisyos opened this issue 1 year ago • 4 comments

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

iisyos avatar Apr 06 '24 10:04 iisyos

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

robcio-ops avatar May 13 '24 12:05 robcio-ops

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

denis256 avatar May 14 '24 17:05 denis256

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.

zackpollard avatar May 29 '24 22:05 zackpollard

What would need to be done for this to be merged?

root0x avatar Mar 04 '25 13:03 root0x