pulumi/tests/integration/get_resource/nodejs/index.ts
Justin Van Patten edc79325fe
Add support for getResource to Node.js SDK (#5837)
And update Node's resource ref deserialization to match Python.

Also, fixed a bug in Python resource ref deserialization that I noticed.
2020-12-01 10:58:15 -08:00

37 lines
882 B
TypeScript

// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
class MyResource extends pulumi.dynamic.Resource {
constructor(name: string, props: pulumi.Inputs, opts?: pulumi.CustomResourceOptions) {
super({
create: async (inputs: any) => {
return {
id: "0",
outs: inputs,
}
},
}, name, props, opts);
}
}
class GetResource extends pulumi.Resource {
foo: pulumi.Output<string>;
constructor(urn: pulumi.URN) {
const props = { foo: undefined };
super("unused:unused:unused", "unused", true, props, { urn });
}
}
const a = new MyResource("a", {
foo: "foo",
});
const getFoo = a.urn.apply(urn => {
const r = new GetResource(urn);
return r.foo
});
export const foo = getFoo;