https://pulumi.com logo
Title
h

helpful-hair-30515

07/02/2021, 2:39 PM
@all I have some issue with pulumi i am trying to create folders and projects in google cloud using pulumi python....i did
pulumi up
and it created the 29 resources after that if i do
pulumi preview
it again deleting the resources i did not change any of my source code i am using pulumi version
3.5.1
This is my code
this is the code
and my
values.yaml
looks like this
@brave-planet-10645 I see you green...any possibility to quick look into it
b

billowy-army-68599

07/02/2021, 3:10 PM
This is a quite irregular use of Pulumi, so it’s not surprising it’s deleting your code to be honest
Can you show your before and after?
I’m on a plane at the moment so my replies may be delayed
h

helpful-hair-30515

07/02/2021, 3:23 PM
i am sorry
i am quite new to pulumi
it looks i need to write a code to track it right
this is my first
pulumi preview
and then i did
pulumi up
to create rrsources in gcp as below
b

billowy-army-68599

07/02/2021, 3:26 PM
Can you elaborate a bit more on what your desired end goal is? Pulumi drives towards a desired state. The fact your names are using outputs is probably going to cause a lot of problems. It might be worth taking a step back and talking about what you’re trying to achieve
h

helpful-hair-30515

07/02/2021, 3:26 PM
like these
I am trying to create GCP folders and then projects and Service account in each project
this is initial setup in my GCP
b

billowy-army-68599

07/02/2021, 3:28 PM
Okay, why are you using yaml and looping through it?
h

helpful-hair-30515

07/02/2021, 3:28 PM
after 29 resources got created i have tried
pulumi preview
again it shows this i am confused
like this
cause i don't want to hard code values in my python
all i declare in yaml file and my python code take it from it and create resources
and in future if i want to create another resources i just add in yaml file and pulumi should create it automatically right
b

billowy-army-68599

07/02/2021, 3:38 PM
The way you’re walking the yaml tree and creating the resources looks like it’s changing the end state every time
h

helpful-hair-30515

07/02/2021, 3:42 PM
oh is it possible see the state
atleast for debugging
b

billowy-army-68599

07/02/2021, 3:51 PM
pulumi stack export
h

helpful-hair-30515

07/02/2021, 3:51 PM
ahh it's changing the resources. i want to know why...the output object from
pulumi preview
to
pulumi up
changing is it a bug in pulumi on pulumi prview <pulumi.output.Output object at 0x7fd0c03d2c10>-srihanuman-matrix-dev create on pulumi up <pulumi.output.Output object at 0x7f96e3bceca0>-srihanuman-matrix-dev create
b

billowy-army-68599

07/02/2021, 3:52 PM
Again, I'll reiterate: this isn’t a normal use of Pulumi and I’d love to get an idea of why you’re walking the tree in this way and reading values from a yaml file when you can define these resources directly in code
h

helpful-hair-30515

07/02/2021, 3:53 PM
Our idea is not to store values inside code
we create separate
values.yaml
we pass our values from this file may be later we use
sping
config server to dynamically pass values also to this
values.yaml
filr
I am little confused how this output objecta changing...as per your docs this inputs and ouputs form a dependency graph right
looks in my case its completely broken
this is my python code
values.yaml
and i run locally
pulumi preview
and
pulumi up
as mentioned in this readME
i'm saying that's the bug and that pulumi doesn't expand the value at the right place "The specific issue here is that logical names cannot be constructed from other resource outputs. They must be static strings. Resource inputs (such as name) can be constructed from other resource outputs." so basically, i can't dynamically scope the names of the resources using the parent id
b

billowy-army-68599

07/02/2021, 4:04 PM
It’s not a bug. You’re putting the outputs in your resource ids (which shouldn’t even be possible, but somehow it is) and the outputs resolve differently every time. So what’s happening on your first run is Pulumi saying “I need to create a resource with name x” Then you rerun and because the outputs resolve differently, Pulumi says “okay I previously created a resource with name x but now I need to create a resource with name y” the state definition is differently to how the outputs have resolved
The issue is your “parent” variable which is an output. Remote that from the resource and make it something known at runtime
h

helpful-hair-30515

07/02/2021, 4:11 PM
Sorry my understanding was wrong in this case let me try what you suggested... thank you so much for your prompt reply ... really appreciate it
do you have any recommendations for me
Remove parent varaible from the resource and make it something known at runtime
-> I mean exactly where i need to change at runtime....may be some elaboration so that i can grasp it
b

billowy-army-68599

07/02/2021, 4:16 PM
The part where you use an f string, remove “parent” from that. It’s hard to type the code on my phone
h

helpful-hair-30515

07/02/2021, 4:17 PM
sorry for bothering on your vacation...i see the message you posted that you guys are enjoying long weekend!!! Have a great long weeknd
I will try my level best to make it work
b

billowy-army-68599

07/02/2021, 4:21 PM
Happy to help! Let us know how it goes
h

helpful-hair-30515

07/02/2021, 4:38 PM
Thank you so much now i have fixed it.. the second time
pulumi preview
shows this ...looks its fine
this is how i have modified it
is there anyway to check diff that pulumi gonna replace
🤔
I do
pulumi up
again it throws error saying that
service account
already exists like this ..would make sense i guess
may be let me try with newest GCP pulumi plugin? @billowy-army-68599
b

billowy-army-68599

07/05/2021, 5:46 AM
the newst plugin wont help if the service account already exists - does it?
h

helpful-hair-30515

07/05/2021, 6:00 AM
i think it might be problem with my code i am trying to fix it thanks!!!
@billowy-army-68599 it looks something fishy to me...this is my first
pulumi preview
1.
pulumi preview
and then 2.
pulumi up
it created
29
resources
till here i am good... the problem is if i run 3.
pulumi preview
again it is somehow replacing the Service Accounts and IAM Members....as shown below
it looks somewhere i am missing the logic
if i see the diff in pulumi console its like this...it says operation
delete-replaced
In the diff also it is showing
delete-replaced
why it is showing like that i am quite confused with its logic
This is my latest updated code ...let me know @billowy-army-68599 @brave-planet-10645 Do I need to change anything in my python code to fix it
i think it worked if i use
project.name
and i have project_name and project_id as same
if no changes in infra
pulumi preview
not showing anything
is that expected behaviour?
like this
the code is this now
b

billowy-army-68599

07/05/2021, 3:24 PM
if no changes in infra pulumi preview not showing anything
yes this is expected behaviour, if the resources exist already it won't do anything, as Pulumi has nothing to do. As I mentioned before, pulumi drives towards a desired state
1
🎉 1
😇 1
h

helpful-hair-30515

07/05/2021, 7:11 PM
Thank you sir for all the help...looks pulumi has bright future!!!
We are going to use
pulumi
in our production we may gonna subscribe for enterprise support as well. Going to have call tomorrow on singapore time 8AM with #LizMcCall
b

billowy-army-68599

07/05/2021, 7:59 PM
Awesome! Do you have the call set up?
@glamorous-dress-74224
👋 1
h

helpful-hair-30515

07/05/2021, 8:08 PM
yeah its already been setup by my boss 🙂
one more quick question is it possible to modularize pulumi code i mean can reuse same code as we do using
terraform modules
with specific version of modules....just wondering how to modularize pulumi python code
and like to deploy for different environments like
terraform workspaces
b

billowy-army-68599

07/06/2021, 4:25 AM
I can’t link right now as I’m on mobile, but for modules look for component resources
And for workspaces, we call them stacks
h

helpful-hair-30515

07/06/2021, 9:11 AM
sure I think I got an idea ...anyway let me sync up with you guys tomorrow in our call.