Outputting Resources #7568
-
With terraform, I could output individual resource properties, such as:
Often, I found this cumbersome because while it probably helps terraform identify dependencies, if you have a lot of properties to return for a single resource it's a bit bulky. In those cases, I would simply return the entire vpc resource as an output, and access properties off of that.
or, I could return a new object for specific properties, and just pass that object around. Here's some pseudocode:
Then, I would pass this around as needed, and other modules would simply access its properties. Is this recommended in pulumi? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
No idea if it's the recommended way or not but this is what I do when passing outputs between values between stacks in pulumi. As you noted passing individual properties quickly becomes cumbersome. |
Beta Was this translation helpful? Give feedback.
-
Just for completeness: Exporting an entire resource gets a bit cumbersome as it's JSON-serialized and is generally fairly large. That's why we recommend exporting each value individually, but it certainly can be done as noted above (and I completely get why it's awkward to export each value when you get into more practical builds). However, if you want to reference values across stacks, I think you're looking for stack references. Pulumi uses stack references to share values to other stacks, letting you reference the values elsewhere in your code. |
Beta Was this translation helpful? Give feedback.
Just for completeness: Exporting an entire resource gets a bit cumbersome as it's JSON-serialized and is generally fairly large. That's why we recommend exporting each value individually, but it certainly can be done as noted above (and I completely get why it's awkward to export each value when you get into more practical builds). However, if you want to reference values across stacks, I think you're looking for stack references. Pulumi uses stack references to share values to other stacks, letting you reference the values elsewhere in your code.