You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve apply and all documentation clarity and correctness (#16401)
Clarifies the purpose and proper usage of apply and all methods, adds important warnings about resource creation in callbacks to prevent preview inconsistencies, and fixes syntax errors in code examples to ensure accuracy.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: content/docs/iac/concepts/inputs-outputs/all.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,12 @@ If you need to access and use multiple outputs together, the `all` function acts
20
20
21
21
This can be used to compute an entirely new output value, such as creating a new string by adding or concatenating outputs from two different resources together, or by creating a new data structure that uses their values. Just like with `apply`, the result of `all` is itself an Output<T>.
22
22
23
+
{{< notes type="warning" >}}
24
+
Creating resources inside an `all` callback should be avoided whenever possible. Resources created inside `all` will not appear in `pulumi preview` unless all output values are already known. This means the preview output may not match the actual changes when `pulumi up` is run, making it difficult to understand what changes will be made to your infrastructure.
25
+
26
+
If you need to create a resource that depends on output values, pass the outputs directly as inputs to the resource instead of using `all`. Pulumi will automatically handle the dependency tracking and ensure resources are created in the correct order.
27
+
{{< /notes >}}
28
+
23
29
## Creating a new string
24
30
25
31
Outputs that return to the engine as strings cannot be used directly in operations such as string concatenation until the output value has returned to Pulumi. In these scenarios, you'll need to wait for the value to return using [`apply`](/docs/concepts/inputs-outputs/apply/).
@@ -74,7 +80,7 @@ let connectionString = pulumi.all([sqlServer.name, database.name])
74
80
75
81
{{% choosable language python %}}
76
82
77
-
In python, you can pass in unnamed arguments to `Output.all` to create an Output list, for example:
83
+
In Python, you can pass in unnamed arguments to `Output.all` to create an Output list, for example:
78
84
79
85
```python
80
86
from pulumi import Output
@@ -139,7 +145,7 @@ var connectionString3 = Output.Tuple(sqlServer.name, database.name).Apply(t =>
139
145
140
146
// When all the input values have the same type, Output.all can be used
141
147
var connectionString =Output.all(sqlServer.name(), database.name())
@@ -334,9 +340,3 @@ This example is not applicable in Pulumi YAML.
334
340
{{% /choosable %}}
335
341
336
342
{{< /chooser >}}
337
-
338
-
## Creating a JSON object
339
-
340
-
You can also [create JSON objects](/docs/concepts/inputs-outputs/apply/#outputs-and-json) using multiple output values in Pulumi. Doing so requires the use of `apply` or one of Pulumi's [JSON-specific helpers](/docs/concepts/inputs-outputs/apply/#converting-outputs-to-json).
0 commit comments