hi, after having used Pulumi now for a couple of m...
# getting-started
l
hi, after having used Pulumi now for a couple of months (aws cdk user for many years before this), there's one thing I find incredibly frustrating, and that's dealing with Pulumi's input/output system. The notion of having to do .Apply is cumbersome at best. I'm findding that if I pipe an output directly to an input in another resource, then pulumi just handles it magically. However, since I'm in a real programming language I might want to capture the output, do some string interpolations, maybe combine with output of another resource, and then add the result as the input to a resource. This means that I constantly have to think about where variables come from, am I mutating or passing directly in to the next etc. Just adds a whole new layer of mental gymnastics when I'm coding - a layer I'd very much like to be without. We are soon looking to start training sysadmin-type employees in Pulumi and since they don't have a programming background I know this is an area they will struggle a lot. Am I the only one finding this really cumbersome?
here's an example: I have honestly no idea why this doesn't work, and there's no error anywhere until I look in the resulting resource (these are values that get passed into a helm chart):
I feel like the docs take far too lightly on this, they mostly deal with returing output data out of the stack
b
l
glad to hear it's not just me 🙂
b
I get the need for it but feel the examples are too trivial and maybe some other language constructs could help
l
After dealing with Terraform I love having a system that my IDE understands and can tell me the valid inputs for stuff. It's a lot easier to build a configurable environment. But yeah there's still a lot of black box stuff that bugs me. The input/output system is fine imo, although that may vary by programming language, we use Go. My latest main complaint many parameters supported by the AWS API aren't in the Pulumi SDK.
c
When I was getting started with Pulumi, I used Pulumi AI to help me to figure out how to do various input/output transformations. For example,
Transform an array of ec2 Subnet objects, taking the ID of each object, and returning a StringArrayOutput to provide to an ec2 SecurityGroup subnet ids field
Pulumi AI would usually provide a reasonable answer that I can adapt as I need. --- I feel like I have got a good grasp on how to use Inputs and Outputs now, and this has resulted in me writing a number of utility functions that help quite a bit. For example, a function to convert an array of Pulumi objects into a Pulumi ID StringArrayOutput (perhaps to pass a slice of ec2 subnet IDs to an ec2 security group), or creating a generic sort function that assists when I convert a map into a Pulumi output array.
b
Thanks for the tip! I had come across that before in searches but never tried Pulumi AI. Tried it a bit today and it didn't exactly generate valid code that compiled or logically correct but it was close enough to be helpful. Will have to compare with Claude more.
l
Here's the scenario I butt up against quite often: i'm creating a helm chart with a complex "values" setting (values are just a bunch of nexted dictionaries). These values will be conditionals, so for instance if "stuff=true" then add a new nested thing somewhere in the nested dict. I prefer to create these dicts from the "ground up" to avoid having lots of conditionals/ternaries in the construction of them. However, this poses a problem because if I'm outside a pulumi resource constructor, I'm bound to get into issues with input values. What I can do instead is to construct the entire values dict inside a
Output.Tuple
block, but if one of my inputs are a secret, then that entire block will be marked as "secret" and the diff will be obfuscated. I feel like the docs don't at all mention the different behavior of
Apply
depending on whether or not you're inside our outside a resource constructor, and the limitations in the readability of the diff. I'm very much looking for feedback - how would you construct code where a 5-level deep values dict might need an extra dict block if an input is set?
☝️ adjusting that, it seems like pulumi doesnt "hash" the entire dict if it was created in an
Output.Tuple
statement. Then maybe that's the way do to this.
...hm but tuple don't seem to go well with nullable inputs, so that leaves me back at square 1...