@@ -363,13 +363,15 @@ public DeleteRequest(Urn urn, string id, ImmutableDictionary<string, PropertyVal
363
363
364
364
public sealed class ConstructRequest
365
365
{
366
+ public ProviderResource ? Provider { get ; init ; }
366
367
public string Type { get ; init ; }
367
368
public string Name { get ; init ; }
368
369
public ImmutableDictionary < string , PropertyValue > Inputs { get ; init ; }
369
370
public ComponentResourceOptions Options { get ; init ; }
370
371
371
- public ConstructRequest ( string type , string name , ImmutableDictionary < string , PropertyValue > inputs , ComponentResourceOptions options )
372
+ public ConstructRequest ( ProviderResource ? provider , string type , string name , ImmutableDictionary < string , PropertyValue > inputs , ComponentResourceOptions options )
372
373
{
374
+ Provider = provider ;
373
375
Type = type ;
374
376
Name = name ;
375
377
Inputs = inputs ;
@@ -393,12 +395,14 @@ public ConstructResponse(Urn urn, IDictionary<string, PropertyValue> state, IDic
393
395
394
396
public sealed class CallRequest
395
397
{
398
+ public ProviderResource ? Provider { get ; init ; }
396
399
public ResourceReference ? Self { get ; }
397
400
public string Tok { get ; init ; }
398
401
public ImmutableDictionary < string , PropertyValue > Args { get ; init ; }
399
402
400
- public CallRequest ( ResourceReference ? self , string tok , ImmutableDictionary < string , PropertyValue > args )
403
+ public CallRequest ( ProviderResource ? provider , ResourceReference ? self , string tok , ImmutableDictionary < string , PropertyValue > args )
401
404
{
405
+ Provider = provider ;
402
406
Self = self ;
403
407
Tok = tok ;
404
408
Args = args ;
@@ -611,6 +615,9 @@ class ResourceProviderService : ResourceProvider.ResourceProviderBase, IDisposab
611
615
private Provider ? implementation ;
612
616
private readonly string version ;
613
617
private string ? engineAddress ;
618
+ // More recent versions of the engine send URN and ID of the provider to `Configure`. With that we can construct
619
+ // a `DependencyProviderResource` to use in `Construct` and `Call` to refer to the provider itself.
620
+ private string ? providerSelfReference ;
614
621
615
622
Provider Implementation
616
623
{
@@ -876,6 +883,11 @@ private ImmutableDictionary<string, PropertyValue> Unmarshal(Struct? properties)
876
883
{
877
884
return WrapProviderCall ( async ( ) =>
878
885
{
886
+ // Save the URN and ID for self provider references in Construct/Call later.
887
+ if ( request . HasId && request . HasUrn ) {
888
+ this . providerSelfReference = request . Urn + "::" + request . Id ;
889
+ }
890
+
879
891
var domRequest = new ConfigureRequest ( request . Variables . ToImmutableDictionary ( ) , Unmarshal ( request . Args ) , request . AcceptSecrets ,
880
892
request . AcceptResources ) ;
881
893
using var cts = GetToken ( context ) ;
@@ -1057,7 +1069,13 @@ public override Task<Empty> Delete(Pulumirpc.DeleteRequest request, ServerCallCo
1057
1069
} ,
1058
1070
} ;
1059
1071
1060
- var domRequest = new ConstructRequest ( request . Type , request . Name ,
1072
+ ProviderResource ? provider = null ;
1073
+ if ( providerSelfReference != null )
1074
+ {
1075
+ provider = new DependencyProviderResource ( providerSelfReference ) ;
1076
+ }
1077
+
1078
+ var domRequest = new ConstructRequest ( provider , request . Type , request . Name ,
1061
1079
Unmarshal ( request . Inputs ) , opts ) ;
1062
1080
using var cts = GetToken ( context ) ;
1063
1081
@@ -1098,7 +1116,13 @@ public override Task<Empty> Delete(Pulumirpc.DeleteRequest request, ServerCallCo
1098
1116
1099
1117
domArgs = PatchArgDependencies ( request , domArgs ) ;
1100
1118
1101
- var domRequest = new CallRequest ( self , request . Tok , domArgs ) ;
1119
+ ProviderResource ? provider = null ;
1120
+ if ( providerSelfReference != null )
1121
+ {
1122
+ provider = new DependencyProviderResource ( providerSelfReference ) ;
1123
+ }
1124
+
1125
+ var domRequest = new CallRequest ( provider , self , request . Tok , domArgs ) ;
1102
1126
using var cts = GetToken ( context ) ;
1103
1127
1104
1128
var inlineDeploymentSettings = new InlineDeploymentSettings ( logger , EngineAddress , request . MonitorEndpoint , request . Config ,
0 commit comments