Hey guys, I have two classes (one for backend one ...
# python
s
Hey guys, I have two classes (one for backend one for frontend) that i run one after the other in my main, how can i pass a string between the two? for instance i'm trying to pass the backend's private ip (from the variable used during the instance creation) to the frontend's class. when i tried using pulumi output my string value ended up being some kind of pulumi.output object which probably means perhaps i did not convert it properly, if pulumi output is the solution for my case can someone give me a quick code example for it being used between two classes? Thanks alot 🙂
n
you have to wait for the Output to be ready. Let's imagine the ip is something like:
Copy code
priv_ip = some_pulumi_code
now we have to wait for it to be ready so:
Copy code
priv_id.apply(lambda ip: FrontendClass(ip))
the code should look similar
s
Thank you very much! do you perhaps have a full code example of this or similar pulumi output usage? regardless this really helps me a lot, it looks similar to what i've tried but i might've missed something
n
I can provide some example but not strictly related to IPs
let me prepare a gist
note that StackReference are also
Output
s
oh that's a great example, i'm kinda weak on the python lambda area so i'm wondering if its possible to pass two arguments to the same class, this is what i got to until now(hopefully i got it correctly this time...):
Copy code
ks_db = KSDBServer(ks_id,KSDBServerArgs(ks_id))

ks_db.private_ip.apply(lambda ip: KSAppServer(ks_id,KSAppServerArgs(ks_id,ip),opts=pulumi.ResourceOptions(depends_on=[ks_db])))
basically ignore ks_id, i create the db first and then get the private ip out of it while running apply on the frontend(app) class but what if i have two classes i need args from? other than passing the private ip from the database i also have a class for creating an ALB and i want to pass the alb's id/arn to the frontend class really sorry if i got it completely wrong by the way and thanks again for the amazing help 😅
never mind, i think i figured it out! Thank you so much for the help 😄
n
partypus