5e28a4ab07
This change wires up the new Read RPC method in such a manner that Pulumi programs can invoke it. This is technically not required for refreshing state programmatically (as in pulumi/pulumi#1081), however it's a feature we had eons ago and have wanted since (see pulumi/pulumi#83), and will allow us to write code like let vm = aws.ec2.Instance.get("my-vm", "i-07043cd97bd2c9cfc"); // use any property from here on out ... The way this works is simply by bridging the Pulumi program via its existing RPC connection to the engine, much like Invoke and RegisterResource RPC requests already do, and then invoking the proper resource provider in order to read the state. Note that some resources cannot be uniquely identified by their ID alone, and so an extra resource state bag may be provided with just those properties required. This came almost for free (okay, not exactly) and will come in handy as we start gaining experience with reading live state from resources.
59 lines
3.4 KiB
Protocol Buffer
59 lines
3.4 KiB
Protocol Buffer
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
|
|
|
syntax = "proto3";
|
|
|
|
import "google/protobuf/empty.proto";
|
|
import "google/protobuf/struct.proto";
|
|
import "provider.proto";
|
|
|
|
package pulumirpc;
|
|
|
|
// ResourceMonitor is the interface a source uses to talk back to the planning monitor orchestrating the execution.
|
|
service ResourceMonitor {
|
|
rpc Invoke(InvokeRequest) returns (InvokeResponse) {}
|
|
rpc ReadResource(ReadResourceRequest) returns (ReadResourceResponse) {}
|
|
rpc RegisterResource(RegisterResourceRequest) returns (RegisterResourceResponse) {}
|
|
rpc RegisterResourceOutputs(RegisterResourceOutputsRequest) returns (google.protobuf.Empty) {}
|
|
}
|
|
|
|
// ReadResourceRequest contains enough information to uniquely qualify and read a resource's state.
|
|
message ReadResourceRequest {
|
|
string id = 1; // the ID of the resource to read.
|
|
string type = 2; // the type of the resource object.
|
|
string name = 3; // the name, for URN purposes, of the object.
|
|
string parent = 4; // an optional parent URN that this child resource belongs to.
|
|
google.protobuf.Struct properties = 5; // optional state sufficient to uniquely identify the resource.
|
|
}
|
|
|
|
// ReadResourceResponse contains the result of reading a resource's state.
|
|
message ReadResourceResponse {
|
|
string urn = 1; // the URN for this resource.
|
|
google.protobuf.Struct properties = 2; // the state of the resource read from the live environment.
|
|
}
|
|
|
|
// RegisterResourceRequest contains information about a resource object that was newly allocated.
|
|
message RegisterResourceRequest {
|
|
string type = 1; // the type of the object allocated.
|
|
string name = 2; // the name, for URN purposes, of the object.
|
|
string parent = 3; // an optional parent URN that this child resource belongs to.
|
|
bool custom = 4; // true if the resource is a custom, managed by a plugin's CRUD operations.
|
|
google.protobuf.Struct object = 5; // an object produced by the interpreter/source.
|
|
bool protect = 6; // true if the resource should be marked protected.
|
|
repeated string dependencies = 7; // a list of URNs that this resource depends on, as observed by the language host.
|
|
}
|
|
|
|
// RegisterResourceResponse is returned by the engine after a resource has finished being initialized. It includes the
|
|
// auto-assigned URN, the provider-assigned ID, and any other properties initialized by the engine.
|
|
message RegisterResourceResponse {
|
|
string urn = 1; // the URN assigned by the engine.
|
|
string id = 2; // the unique ID assigned by the provider.
|
|
google.protobuf.Struct object = 3; // the resulting object properties, including provider defaults.
|
|
bool stable = 4; // if true, the object's state is stable and may be trusted not to change.
|
|
repeated string stables = 5; // an optional list of guaranteed-stable properties.
|
|
}
|
|
|
|
// RegisterResourceOutputsRequest adds extra resource outputs created by the program after registration has occurred.
|
|
message RegisterResourceOutputsRequest {
|
|
string urn = 1; // the URN for the resource to attach output properties to.
|
|
google.protobuf.Struct outputs = 2; // additional output properties to add to the existing resource.
|
|
}
|