1. is there any way to access props (inputs) passe...
# python
c
1. is there any way to access props (inputs) passed to a resource? e.g.
Copy code
subnet = aws.ec2.Subnet("subnet", vpc_id="vpc-1234", tags={"Name": "my-custom-name"})
# I want to get {"Name": "my-custom-name"}
specifically inputs, not outputs, which can be known only after creating resource. I was exploring
subnet.___dict___
but didn't find any attribute where props could be stored 2. was it ever considered to have async interface for outputs? e.g. instead of doing something like:
subnet.id.apply(lambda x: print(x))
I would do:
print(await subnet.id)
m
1. Any input is also available as an output. So you can use
subnet.tags
and handle it like any other output. 2. This doesn't work, because the output values are not available at program runtime. They are only resolved later (see https://www.pulumi.com/docs/iac/concepts/inputs-outputs/#outputs) and thus cannot be converted into plain/"native" types or printed (which would require converting an output into a string first).
c
@modern-zebra-45309 thanks, but I don't think any of these answers address my questions. 1. if I want to access output, I need to do apply. this defeats what I am asking as my input is available before we start infra provisioning 2. I understand how outputs work. that's exactly why I am asking if async python was ever considered as an interface instead of the callback.
await
would allow to continue running the program when the dependent resource has been provisioned, no?
m
I think it could help to describe what you're ultimately trying to accomplish here, to avoid discussing XY problems 🙂
I understand how outputs work. that's exactly why I am asking if async python was ever considered as an interface instead of the callback.
await
would allow to continue running the program when the dependent resource has been provisioned, no?
No, that doesn't work, because resources are not provisioned in the order in which the program runs. The program declares the infrastructure state you want to have, producing a graph (DAG). Then, Pulumi takes this desired state and compares it to what's there, taking into account and resolving all resource dependencies. Running the same program leads to very different activities and orders depending on the current infrastructure state.
if I want to access output, I need to do apply. this defeats what I am asking as my input is available before we start infra provisioning
If you're the one setting the tag, you have access to it, no?
Copy code
my_tags = {"key": "some value"}
subnet = aws.ec2.subnet(..., tags=my_tags)
my_extended_tags = {**my_tags, "extra-key": "some value"}
subnet2 = aws.ec2.subnet(..., tags=my_extended_tags)
And if you don't know the tags as a plain value in your program, then you cannot know the tags in advance. (I'm a bit fuzzy on the details but I'm pretty sure that external processes, e.g., auto tagging, can modify the resource's tags, further complicating the situation.)