Hi, I am trying to work with instantiating objects...
# getting-started
c
Hi, I am trying to work with instantiating objects ad-hoc and it looks like this creates a major problem with referencing other objects - I cannot reference them because they have yet to be created. I’m using the method suggested by fraser above (see that discussion). I can’t “translate” even this standard snippet to this method: vpc = ec2.Vpc( “myvpc”, cidr_block=“10.0.0.0/16”) igw = ec2.InternetGateway( “myinternetgateway”, vpc_id=vpc.id) if there was an introspection method to extract the constructor and parameters dynamically, maybe it would have worked
b
following the other thread, it seems like you’re trying to do a series of imperative actions?
c
exactly. this is what drew me to pulumi to begin with - it's impossible to do with straight terraform/cf/etc and not sure their respective CDKs are amenable to it, too. it's crucial to our use case - it's a go-no go
if that fails we'll go with crossplane but I find that prospect much less pleasing for the task
the requirement is to interleave imperative actions with other imperative python code (host provisioning, tests etc)
b
I don’t think crossplane can do this either. If you want imperative actions you likely can’t use any declarative tool
I’m not sure how you can achieve this in Pulumi
c
I can but it's quite backwards. my pulumi program looks something like this: <bunch of resources> if <flag>: <bunch of additional resources> <resource modifications> then main looks like this: stack.up # do some stuff here flag = True stack.up # do more stuff here (...) this emulates it, but very awkwardly.
the same would be in crossplane: # push some resources to k8s # do stuff # push resource updates # do stuff (...) but I strongly prefer pulumi for this case because it's far better integrated with my code for things like introspection of created resources