https://pulumi.com logo
g

great-sunset-355

08/03/2021, 9:28 AM
If a resource component requires 2 AWS providers how can I reference that in the component's code? I know that
ResourceOptions
has a
providers
argument
Copy code
opts = ResourceOptions(providers={"prov-name": provider_resource})
Is this the correct way to reference the provider?
Copy code
opts.providers["prov-name"]
I wonder what error I get if the
providers
dict does not contain the required provider - I assume it's general
KeyError
right?
b

brave-planet-10645

08/03/2021, 9:38 AM
I would pass them in either as two separate parameters or a dictionary / array. Then reference them like:
Copy code
opts = ResourceOptions(provider=provider_array[0])
g

great-sunset-355

08/03/2021, 11:02 AM
Yes two separate parameters was my first go to. I got puzzled by the
providers
being an
dictionary / array
- which mixes 2 completely different structures when it comes to access to the items. I'll make the provider/s an explicit parameter