great-sunset-355
12/14/2021, 9:52 AMpulumi.ResourceOptions(providers={mapping}
work?
I looked at the type description but it's not helpful and nor is the docstring.
Because when the resource is created like this:
opts = pulumi.ResourceOptions(
parent=self,
provider=classic_aws_provider,
)
and later on opts
is modified to use providers
parameter
opts- pulumi.ResourceOptions(
parent=self,
providers={'aws':classic_aws_provider, 'aws-native':aws_native_provider},
)
Pulumi results in creating default
aws provider and completely ignore providers
prehistoric-activity-61023
12/14/2021, 10:06 AMproviders
is of type:
Optional[Union[Mapping[str, 'ProviderResource'], List['ProviderResource']]]
...
providers=[classic_aws_provider, aws_native_provider])
...
self
as a parent)Note: do not provide both provider and providers.
and later onI’m afraid you might somehow set both parameters and that’s the root cause of this.is modified to useopts
parameterproviders
great-sunset-355
12/14/2021, 10:25 AMyou 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
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
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 mappingprehistoric-activity-61023
12/14/2021, 10:58 AMprovider
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?great-sunset-355
12/14/2021, 11:19 AMRegarding the default providerYes 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
.prehistoric-activity-61023
12/14/2021, 11:22 AMpulumi.ResourceOptions.merge
great-sunset-355
12/14/2021, 11:26 AMprint
{'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