pulumi/sdk
Justin Van Patten 0650e8bbbb
[sdk/nodejs] Fix provider for resource methods (#13796)
The `Resource` class in the Node.js SDK has the following internal
property:

```typescript
/** @internal */
readonly __prov?: ProviderResource;
```

When a resource is created, the provider specified for the resource is
stored in this property. If it is set, it is passed along in the `Call`
request when a method is called on the resource.

Prior to #13282, the property was only set for custom resources in
`Resource`'s constructor:

```typescript
this.__prov = custom ? opts.provider : undefined;
```

With #13282, it was changed to also store the value for remote
components:

```diff
- this.__prov = custom ? opts.provider : undefined;
+ this.__prov = custom || remote ? opts.provider : undefined;
```

This regressed the behavior when calling a method on a remote component
that had an explicit provider that wasn't the component provider, but
some other provider (e.g. AWS provider) specified as:

```typescript
const component = new MyRemoteComponent("comp", {
}, { provider: awsProvider });
```

The `awsProvider` was being stored in `Resource.__prov`, and when making
the method call on the resource, it would try to invoke `Call` on the
AWS provider, rather than calling the remote component provider's
`Call`, which resulted in an error.

Note that specifying the AWS provider using the more verbose `providers:
[awsProvider]` works around the issue.

The fix is to only set `__prov` if the provider's package is the same as
the resource's package. Otherwise, don't set it, because the user is
specifying a provider with the `provider: awsProvider` syntax as
shorthand for `providers: [awsProvider]`.

Fixes #13777
2023-08-30 14:49:53 +00:00
..
go plugin(go, node, py): Exit cleanly on interrupt (#13809) 2023-08-29 15:42:31 +00:00
nodejs [sdk/nodejs] Fix provider for resource methods (#13796) 2023-08-30 14:49:53 +00:00
proto/go Allow language plugins to return plugin checksums (#13776) 2023-08-25 15:26:25 +00:00
python plugin(go, node, py): Exit cleanly on interrupt (#13809) 2023-08-29 15:42:31 +00:00
README.md Cleanup sdk/README.md 2023-01-03 17:12:12 -05:00
go.mod [cli/new] Support SSH-style Git URLs 2023-08-02 09:29:34 -07:00
go.sum deps: Upgrade google.golang.org/{genproto, grpc} 2023-07-27 16:24:33 -07:00

README.md

Pulumi Language SDKs

This directory contains Pulumi SDKs for the following languages:

See the respective READMEs for information about installing and using these libraries.

The language providers work by implementing gRPC interfaces defined in the top level directory proto.