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

Identify after_hook trigger #3211

Open
2 tasks
emilkor1 opened this issue Jun 18, 2024 · 0 comments
Open
2 tasks

Identify after_hook trigger #3211

emilkor1 opened this issue Jun 18, 2024 · 0 comments
Assignees
Labels
accepted Accepted RFC rfc Request For Comments

Comments

@emilkor1
Copy link

Summary

A way to identity the after_hook trigger if hook can be triggered by multiple commands

Motivation

I am running an after_hook which executes on both commands plan and apply.

The hook starts a Go script which creates database users.

I wish to know within the script which of those has initiated the trigger such that I can print the outcome of what will happen when an apply will be performed (simply a dry run of the script).

Proposal

A simplified version of the hook:

terraform {
  after_hook "create_users" {
    commands = ["plan", "apply"]
    execute = [
      "go", "run", "main.go",
    ]
  }
}

For my use case, this is a Go CLI with quite many arguments, thus I do not want to split it into two distinct after_hooks. I also have to update the CLI arguments on both hooks for it to work in that case.

My proposal is for example to add some type of environment variable such that I can do a os.Getenv(...) in the Go script.

Technical Details

A non-breaking feature for hooks.

Press Release

A new environment variable for hooks to distinguish between triggers.

Drawbacks

No drawbacks.

Alternatives

No response

Migration Strategy

No response

Unresolved Questions

Any alternative or existing solution?

References

No response

Proof of Concept Pull Request

No response

Support Level

  • I have Terragrunt Enterprise Support
  • I am a paying Gruntwork customer

Customer Name

No response

@emilkor1 emilkor1 added pending-decision Pending decision from maintainers rfc Request For Comments labels Jun 18, 2024
@yhakbar yhakbar added accepted Accepted RFC and removed pending-decision Pending decision from maintainers labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Accepted RFC rfc Request For Comments
Projects
None yet
Development

No branches or pull requests

2 participants