Support action blocks and action_trigger lifecycle properties
Community note
[!TIP] Hi there, OpenTofu community! The OpenTofu team prioritizes issues based on upvotes. Please make sure to upvote this issue and describe how it affects you in detail in the comments to show your support.
OpenTofu Version
OpenTofu v1.10.6
on linux_amd64The problem in your OpenTofu project
Terraform 1.14 will add new action blocks that declare actions that can be triggered by certain lifecycle events on.
This allows a cleaner approach to performing certain actions in between applying terraform changes.
Also, one potential advantage it has over provisioners, is that the action can make use of provider configuration (for example, AWS credentials), whereas with normal provisioners such configuration would need to be passed to a command via some out-of-band mechanism. Another advantage is that it doesn't rely on additional tools (such as the aws cli) being installed on the host running OpenTofu.
See:
- https://mattias.engineer/blog/2025/terraform-actions-deep-dive/#chain-multiple-actions-together
- https://pkg.go.dev/github.com/hashicorp/[email protected]/action
- https://github.com/hashicorp/terraform/blob/v1.14/CHANGELOG.md#1140-unreleased
Attempted Solutions
See Workarounds and Alternatives
Proposal
Implement a feature similar Terraform's actions feature.
Right now, I don't have a strong opinion on whether the syntax exactly matches what terraform has, although if this sees usage in public modules, then it would probably be advantageous for it to be compatible with what terraform uses.
I also don't really care about the ability to invoke actions from the terraform cli, although other users may feel differently.
Workarounds and Alternatives
The current solution would be to use provisioners to run a command. Possibly using a terraform_data resource. But that has downsides, as mentioned above.
In some cases it may be possible to use aws_lambda_invocation, assuming you are using AWS, and your needs match the way that resource works.
References
No response
Source: opentofu/opentofu