able-airport-31667
07/08/2023, 12:25 PMpulumi dynamic resource provider
.
Is there any chance to pass pulumi.Resource
as an Input
parameter to another pulumi.Resource
?
Example (Foo resource passed as an Input to Bar resource inputs):
# Foo Resource
class Foo(Resource):
foo_out_1: Output[str]
foo_out_2: Output[str]
foo_out_3: Output[str]
def __init__(self, name: str, props: FooInputs, opts=None) -> None:
super().__init__(FooProvider(),
name=name,
props={
**vars(props),
},
opts=opts)
# Bar Resource
class BarInputs:
name: Input[str]
foo_resource: Input[Foo] #<-- Passed Foo resource as an Input
class BarProvider(ResourceProvider):
def create(self, args):
print(args['foo_resource'])
# Expected output:
# {
# "foo_out_1": "value1",
# "foo_out_2": "value2",
# "foo_out_3": "value3",
# }
billowy-engine-58246
07/09/2023, 1:42 PMable-airport-31667
07/12/2023, 8:07 PMBar
Resource needs 3 parameters related to Foo
resource.
Then I think it will be more user friendly to write:
Bar(
name="my_resource_name",
foo_object=foo_resource,
)
rather than
Bar(
name="my_resource_name",
foo_input_1=foo_resource.foo_out_1,
foo_input_2=foo_resource.foo_out_2,
foo_input_3=foo_resource.foo_out_3,
)