Skip to content

Conversation

@Frassle
Copy link
Member

@Frassle Frassle commented Oct 29, 2025

This adds support for terraform provider actions, exposing them as invokes. Every invoke takes the parameters for the action plus a resource URN so that we can log the action output messages against a specific resource.

The intention of these is to use them inside resource lifecycle hooks (where you'll have access to the resource URN), and is very similar to how terraform intends to use these actions. Of course being invokes users could also make use of these anywhere else as well, but as their generally mutating/side-effectful operations you probably don't want to do that.

This prototype currently has a "preview" flag being passed to the invoke as well. This is so we can call PlanAction rather than InvokeAction at preview time. I'm going to look at adding that directly to the engine-provider invoke interface as that would allow pulumi to have side-effectful invokes in general. (pulumi/pulumi#20827)

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 52.30769% with 279 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.85%. Comparing base (4c91969) to head (8930715).

Files with missing lines Patch % Lines
pkg/tfgen/generate.go 59.68% 37 Missing and 15 partials ⚠️
pkg/pf/tfbridge/provider_invoke.go 64.07% 24 Missing and 13 partials ⚠️
pkg/pf/proto/action.go 7.40% 25 Missing ⚠️
pkg/tfshim/util/filter.go 0.00% 20 Missing ⚠️
pkg/tfshim/schema/action.go 9.52% 19 Missing ⚠️
pkg/tfshim/sdk-v1/action.go 0.00% 18 Missing ⚠️
pkg/tfshim/sdk-v2/action.go 11.11% 16 Missing ⚠️
pkg/pf/internal/schemashim/actions_map.go 54.54% 14 Missing and 1 partial ⚠️
pkg/pf/proto/runtypes.go 16.66% 14 Missing and 1 partial ⚠️
pkg/pf/tfbridge/naming.go 0.00% 12 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3226      +/-   ##
==========================================
- Coverage   68.62%   63.85%   -4.77%     
==========================================
  Files         338      326      -12     
  Lines       44181    36009    -8172     
==========================================
- Hits        30318    22994    -7324     
+ Misses      12128    11193     -935     
- Partials     1735     1822      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

github-merge-queue bot pushed a commit to pulumi/pulumi that referenced this pull request Nov 3, 2025
…ime (#20827)

Influenced by adding [support for terraform
actions](pulumi/pulumi-terraform-bridge#3226),
but the idea is generally useful for pulumi invokes.

With this providers can safely write side-effectful or mutating invokes
as they can tell they're running at preview time and switch to not
actually doing the mutating work. This should be particuarlly useful for
invokes to be used in lifecycle hooks (which by default don't run at all
at preview time, but can be flagged by the user if they're only using
safe operations in the hook).

It may transpire there are other useful cases for side-effectful
operations outside lifecycle hooks, and this is general enough to allow
those if they arise.

---------

Co-authored-by: Thomas Gummerer <[email protected]>
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.

1 participant