10BC0 actions: add invoke nodes to the graph by liamcervante · Pull Request #37521 · hashicorp/terraform · GitHub
[go: up one dir, main page]

Skip to content

Conversation

liamcervante
Copy link
Member

This PR adds new "invoke" nodes into the plan graph that are added when the -invoke flag is used in the CLI.

This PR also makes the -invoke flag experimental, as the action config blocks are also experimental.

The approach is to modify the action plan transformer so when it has actions to invoke instead of adding triggers from the configuration, it instead adds nodes based on the targeted actions. The apply operation doesn't actually need any changes, as they already trigger based on the invocations in the plan and both types of triggers (lifecycle and invoked) are put into the plan the same way.

Target Release

1.14.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@liamcervante liamcervante requested a review from a team as a code owner August 29, 2025 08:33
@liamcervante liamcervante added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Aug 29, 2025
Copy link
Contributor
@DanielMSchmidt DanielMSchmidt left a comment
10BC0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🎉


func NewActionStart(id terraform.HookActionIdentity) Hook {
at, ok := id.ActionTrigger.(plans.LifecycleActionTrigger)
at, ok := id.ActionTrigger.(*plans.LifecycleActionTrigger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore if this is in another PR, but wouldn't you need to handle InvokeActionTrigger here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this - I'll do the JSON outputs in a follow up PR.

}

if at, ok := aiSrc.ActionTrigger.(plans.LifecycleActionTrigger); ok {
if at, ok := aiSrc.ActionTrigger.(*plans.LifecycleActionTrigger); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought we would want to somehow serialize that it's an invoke triggered action here as well, just the absence of a lifecycle seems a bit ambiguous if we might add new ways of triggering actions in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this - I'll do the JSON outputs in a follow up PR.


expectDiagnostics func(m *configs.Config) tfdiags.Diagnostics
}{
"unreferenced": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test doesn't make sense in the context of an apply. The plan returned by this configuration and options is a no-op, and has Applyable = false. I added a check below for all the other tests that applyable is set to true, we're expecting valid plans for all the other tests, but this one just isn't valid so I took it out.

There's still the plan test equivalent that makes sure this plans successfully, but then produces a non-applyable plan.

@@ -0,0 +1,186 @@
// Copyright (c) HashiCorp, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can't re-use node_action_trigger_plan / apply here. From what I understand broadly speaking we are doing the same at the point where we have action addrs. It's just that there is a bit of lifecycle specific work done before in the trigger node.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll dig into this a bit more in a follow up PR. I did try to merge the code paths, but essentially the logic in this node is so simple that trying to share made the whole thing more complicated overall so I felt just keeping them separate was better.

@liamcervante liamcervante merged commit 866363f into main Aug 29, 2025
7 checks passed
@liamcervante liamcervante deleted the liamcervante/action-invoke/graph branch August 29, 2025 12:43
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0