It’s hard to read the code as I’m on mobile at the moment, but a few notes.
Resource names must have known values when they’re created, so as you noted, it you want to create a resource name from the output of another resource you’d need to do it inside an apply.
However
Creating resources inside an apply is generally not recommend because it means previews aren’t correct.
The best way to move forward for your issue I think is to decide on a name prefix as a string variable and pass that to every resource
billowy-army-68599
12/30/2022, 11:22 AM
So basically, make the project id a string
a
adventurous-apartment-93389
12/30/2022, 11:30 AM
That makes sense but I am struggling to make project Id a string - I could generate a random string but again that's a StringOuput unless I use a golang native rand function which doesn't get committed to state which means on every run it mutates.
b
billowy-army-68599
12/30/2022, 11:35 AM
What I mean is, set the type on the struct as a string instead of a string output and don’t use an apply at all. You can’t convert an output to a string, ever.
This may help:
https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.