docs(concepts): clarify the difference between direct-form and output-form provider functions#18931
docs(concepts): clarify the difference between direct-form and output-form provider functions#18931joeduffy wants to merge 2 commits into
Conversation
Two changes to content/docs/iac/concepts/functions/provider-functions.md:
1. Add an explicit statement (just before the "Direct form" subsection) that
the two variations are two distinct, separately named functions in most
languages — not overloads of a single function. Includes the concrete
naming examples (aws.ec2.getAmi / aws.ec2.getAmiOutput, Java's inverted
convention, and YAML's single fn::invoke form).
2. Add a pair of choosable code examples at the end of the "Choosing between
direct form and output form" section illustrating the two common scenarios:
- Direct form used to gate whether a resource is created at all (the lookup
result must be a plain value for the Pulumi engine to resolve the
dependency graph).
- Output form used when an existing Output value (e.g. a config secret)
feeds directly into the lookup's arguments, avoiding an apply() wrapper.
Fixes #12373
Docs reviewSolid addition that addresses the gaps in #12373. The cross-language coverage is thorough and the examples are realistic and consistent with the page's existing style. A few small things to consider before merging: Awkward colon at the section lead-in (line 237)The original sentence ends with a colon:
That colon was previously introducing the Minor redundancy (line 239)
"distinct" and "separately named" overlap. Tightening this would help: Inconsistent Python filter style between the two examplesThe direct-form Python example (around line 396) uses a plain dict for the filter: filters=[{\"name\": \"name\", \"values\": [\"amzn2-ami-hvm-*-x86_64-gp3\"]}],The output-form Python example (around line 610) uses the typed argument class: filters=[aws.ec2.GetAmiFilterArgs(name=\"name\", values=[ami_name_filter])],Both work, but mixing styles in adjacent examples is the kind of thing a careful reader will trip on. Recommend picking one (typed args are the more discoverable, IDE-friendly choice) and using it in both. YAML "direct form" example doesn't actually demonstrate the direct formThe YAML direct-form example (around line 533) carries a comment explaining that YAML can't do conditional resource creation, and then proceeds to write an Two options:
Nits
Mention @claude if you'd like another pass after revisions. |
- Change 'in two variations:' to a period (colon was left dangling by new para) - Remove redundant 'distinct' from 'two distinct, separately named functions' - Replace plain dict filter with GetAmiIdsFilterArgs in Python direct-form example, matching the typed-args style used in the output-form Python example - Drop YAML from the direct-form chooser; add an info note explaining YAML does not distinguish between direct and output forms at the language level - Replace wildcard 'import com.pulumi.*' with explicit Context/Pulumi imports in both new Java examples for consistency with the page's existing style - Change 'no apply wrapper required' to 'no apply call required' (no backticks)
|
Thanks for the detailed review! Addressed all feedback in the follow-up commit:
|
|
Claude finished @joeduffy's task in 1m 39s —— View job Follow-up commit review — all feedback addressed ✅Reviewed
Structural sanity checks
LGTM — ready to merge from a docs-review standpoint. Nothing else jumped out on this pass. |
|
Your site preview for commit 16aca83 is ready! 🎉 http://www-testing-pulumi-docs-origin-pr-18931-16aca834.s3-website.us-west-2.amazonaws.com |
What changed
This PR makes two changes to the Provider functions concepts page to address the gaps described in issue #12373.
Change 1 — clarify that the two forms are distinct functions, not overloads
A new paragraph has been added immediately before the "Direct form" subsection to state plainly that in most languages the two variations are two separately named functions rather than overloads of a single function. It includes the concrete naming examples (
aws.ec2.getAmi/aws.ec2.getAmiOutput), calls out Java's inverted convention (getAmi()is the output form,getAmiPlain()is the direct form), and notes that YAML usesfn::invokefor both.Change 2 — concrete code examples showing when to choose each form
Two new choosable code blocks have been added at the end of the "Choosing between direct form and output form" section, one per form:
getAmiIdsto look up AMIs and gates instance creation on whether any matching AMIs were found — illustrating that the direct form returns plain values suitable for conditional logic.getAmiOutput(and its per-language equivalents) with a config secret (requireSecret) as a filter value — illustrating that the output form accepts PulumiInputvalues directly, avoiding anapply()wrapper.Both examples use AWS EC2 AMI lookups, consistent with the existing examples on the page, and are provided for TypeScript, Python, Go, C#, Java, and YAML.
Verification
---delimiters confirmed.{{< chooser >}}and{{% choosable %}}tags balanced (5 chooser blocks, 30 choosable blocks).provider-functions.mdis hand-authored content, not auto-generated.Fixes #12373
🧠 This PR was created by workprentice on behalf of @joeduffy.