This message was deleted.
# getting-started
s
This message was deleted.
p
let me check my projects, I think I’ve got one where I needed to use 2 providers
ok, I see that
providers
is of type:
Copy code
Optional[Union[Mapping[str, 'ProviderResource'], List['ProviderResource']]]
and I actually used a list (every provider is a different type so you don’t need to name them)
but I think your approach should work as well
can you try to pass these providers as list and see if that helps?
Copy code
...
   providers=[classic_aws_provider, aws_native_provider])
...
keep in mind that resources inherit their parent providers so in most cases, you don’t need to explicitly specify providers in child resources (or within ComponentResource classes where you usually assign
self
as a parent)
btw, there’s also a note saying:
Copy code
Note: do not provide both provider and providers.
If the tip above doesn’t work, could you explain what you meant by:
and later on 
opts
 is modified to use 
providers
 parameter
I’m afraid you might somehow set both parameters and that’s the root cause of this.
g
P.S.
you don’t need to explicitly specify providers
- this lead to many problems that created a silent default provider for whatever reason and that's what I want to avoid. I also tried the
list
and it did not go well. Because pulumi silently used a
default
provider. This is what I'm trying to achieve, but I may be misunderstanding something
Copy code
self._opts = pulumi.ResourceOptions.merge(
            opts,
            pulumi.ResourceOptions(
                parent=self,
                providers=[aws_classic_provider, aws_native_provider],
            ),
        )

        classic_role = aws_classic.iam.Role(
            f"{self._config.name}-classic-role",
            args=aws_classic.iam.RoleArgs(assume_role_policy=json.dumps(assume_policy), tags=self._config.tags),
            opts=self._opts,    # here I expect Pulumi to pick my classic provider
        )

        native_role = aws_native.iam.Role(
            f"{self._config.name}-native-role",
            args=aws_native.iam.RoleArgs(
                assume_role_policy_document=assume_policy
            ),
            opts=self._opts  # here I expect my native provider
        )
but the code below ends with
Copy code
pulumi:providers:aws-native       default_4_32_0                               1 error

pulumi:providers:aws-native (default_4_32_0):
    error: no resource plugin 'aws-native-v4.32.0' found in the workspace or on your $PATH, install the plugin using `pulumi plugin install resource aws-native v4.32.0`
It looks like something is confused by the mapping
p
Regarding the default provider - in my project I stopped using default provider configuration completely. Everything except ResourceComponents (that rely on parent providers) receives explicit providers.
If I find some time, I’ll try to repro it locally on my side. My current guess is that you defined both
provider
and
providers
. Can you add a simple print debugging statement and check how this
self._opts
actually looks like? Plus, can you confirm that these resources are created within ComponentResource definition (this is what I assumed based on
parent=self
)? If so, how are you creating this resource? Do you specify any
opts
in the constructor?
g
Regarding the default provider
Yes me too, that's why I inspect the state to make sure that the default provider is not created somehow.
that you defined both provider and providers.
No only
providers
heck how this self._opts actually looks like?, ... ComponentResource definition (this...
yes it is a ComponentResource and I do not pass
provider
to the constructor, nor
providers
. When my ComponentResources need provider I ask for that explicitly rather than assuming it from
opts
.
p
🤔
the other difference I see is that you used
pulumi.ResourceOptions.merge
maybe it’s related to that
g
I doubt that. Here is what I got with the
print
Copy code
{'merge': <bound method ResourceOptions._merge_instance of <pulumi.resource.ResourceOptions object at 0x7f42bfb39910>>, 'parent': <tqs_infrastructure.components.native_fargate.FargateApp object at 0x7f42bfb39370>, 'protect': None, 'provider': None, 'providers': {'aws': <pulumi_aws.provider.Provider object at 0x7f42bfbd2d90>, 'aws-native': <pulumi_aws_native.provider.Provider object at 0x7f42bfb64370>}, 'delete_before_replace': None, 'ignore_changes': None, 'version': None, 'aliases': None, 'additional_secret_outputs': None, 'custom_timeouts': None, 'id': None, 'import_': None, 'transformations': None, 'urn': None, 'replace_on_changes': None, 'depends_on': []}
to me this looks as expected, though the result is unexpected