pulumi/tests/integration/query/step3/index.ts
Alex Clemmer 02788b9b32 Implement listResourceOutputs in the Node.js SDK
This commit will expose the new `Invoke` routine that lists resource
outputs through the Node.js SDK.

This API is implemented via a new API, `EnumerablePromise`, which is a
collection of simple query primitives built onto the `Promise` API. The
query model is lazy and LINQ-like, and generally intended to make
`Promise` simpler to deal with in query scenarios. See #2601 for more
details.

Fixes #2600.
2019-06-03 14:56:49 -07:00

26 lines
954 B
TypeScript

// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
// Step 3: Run a query during `pulumi query`.
pulumi.runtime
.listResourceOutputs(undefined, `moolumi/${pulumi.runtime.getStack()}`)
.groupBy<string, pulumi.Resource>(r => (<any>r).__pulumiType)
.all(async function(group) {
const count = await group.count();
if (group.key === "pulumi-nodejs:dynamic:Resource" && count !== 2) {
throw Error(`Expected 2 registered resources, got ${count}`);
}
console.log(group.key);
return (
group.key === "pulumi-nodejs:dynamic:Resource" ||
group.key === "pulumi:providers:pulumi-nodejs" ||
group.key === "pulumi:pulumi:Stack"
);
})
.then(res => {
if (res !== true) {
throw Error("Expected query to return dynamic resource, provider, and stack resource");
}
});