Fork me on GitHub

Module runtime

@pulumi/pulumi > runtime


runtime/closure/createClosure.ts runtime/closure/parseFunction.ts runtime/closure/rewriteSuper.ts runtime/closure/serializeClosure.ts runtime/closure/v8.ts runtime/config.ts runtime/debuggable.ts runtime/invoke.ts runtime/resource.ts runtime/rpc.ts runtime/settings.ts runtime/stack.ts

const rootPulumiStackTypeName

const rootPulumiStackTypeName: pulumi:pulumi:Stack = "pulumi:pulumi:Stack";

rootPulumiStackTypeName is the type name that should be used to construct the root component in the tree of Pulumi resources allocated by a deployment. This must be kept up to date with

const specialArchiveSig

const specialArchiveSig: 0def7320c3a5731c473e5ecbe6d01bc7 = "0def7320c3a5731c473e5ecbe6d01bc7";

specialArchiveSig is a randomly assigned hash used to identify archives in maps. See pkg/resource/asset.go.

const specialAssetSig

const specialAssetSig: c44067f5952c0a294b673a41bacd8c17 = "c44067f5952c0a294b673a41bacd8c17";

specialAssetSig is a randomly assigned hash used to identify assets in maps. See pkg/resource/asset.go.

const specialSigKey

const specialSigKey: 4dabf18193072939515e22adb298388d = "4dabf18193072939515e22adb298388d";

specialSigKey is sometimes used to encode type identity inside of a map. See pkg/resource/properties.go.

const unknownValue

const unknownValue: 04da6b54-80e4-46f7-96ec-b56ff0331ba9 = "04da6b54-80e4-46f7-96ec-b56ff0331ba9";

Unknown values are encoded as a distinguished string value.

function allConfig

allConfig(): { ... }

allConfig returns a copy of the full config map.

function createFunctionInfoAsync

createFunctionInfoAsync(func: Function, serialize: { ... }): Promise<FunctionInfo>

createFunctionInfo serializes a function and its closure environment into a form that is amenable to persistence as simple JSON. Like toString, it includes the full text of the function’s source code, suitable for execution. Unlike toString, it actually includes information about the captured environment.

function debuggablePromise

debuggablePromise<T>(p: Promise<T>, ctx?: any): Promise<T>

debuggablePromise optionally wraps a promise with some goo to make it easier to debug common problems.

function deserializeProperties

deserializeProperties(outputsStruct: any): any

deserializeProperties fetches the raw outputs and deserializes them from a gRPC call result.

function deserializeProperty

deserializeProperty(prop: any): any

deserializeProperty unpacks some special types, reversing the above process.

function disconnect

disconnect(): void

disconnect permanently disconnects from the server, closing the connections. It waits for the existing RPC queue to drain. If any RPCs come in afterwards, however, they will crash the process.

function disconnectSync

disconnectSync(): void

disconnectSync permanently disconnects from the server, closing the connections. Unlike disconnect. it does not wait for the existing RPC queue to drain. Any RPCs that come in after this call will crash the process.

function errorString

errorString(err: Error): string

errorString produces a string from an error, conditionally including additional diagnostics.

function getConfig

getConfig(k: string): string | undefined

getConfig returns a configuration variable’s value or undefined if it is unset.

function getEngine

getEngine(): Object | undefined

getEngine returns the current engine, if any, for RPC communications back to the resource engine.

function getFunctionFile

getFunctionFile(func: Function): string

Given a function, returns the name of the file where this function was defined. Returns the empty string if the given function has no Script. (e.g. a native function)

function getFunctionLocation

getFunctionLocation(func: Function): { ... }

Given a function, returns the line and column number in the file where this function was defined. Returns { 0, 0 } if the location cannot be found or if the given function has no Script.

function getMonitor

getMonitor(): Object

getMonitor returns the current resource monitoring service client for RPC communications.

function getProject

getProject(): string | undefined

Get the project being run by the current update.

function getRootResource

getRootResource(): ComponentResource | undefined

getRootResource returns a root resource that will automatically become the default parent of all resources. This can be used to ensure that all resources without explicit parents are parented to a common parent resource.

function getStack

getStack(): string | undefined

Get the stack being targeted by the current update.

function hasMonitor

hasMonitor(): boolean

hasMonitor returns true if we are currently connected to a resource monitoring service.

function invoke

invoke(tok: string, props: Inputs, opts?: InvokeOptions): Promise<any>

invoke dynamically invokes the function, tok, which is offered by a provider plugin. The inputs can be a bag of computed values (Ts or Promises), and the result is a Promise that resolves when the invoke finishes.

function isDryRun

isDryRun(): boolean

Returns true if we’re currently performing a dry-run, or false if this is a true update.

function isLegalFunctionName

isLegalFunctionName(n: string): boolean

function isLegalMemberName

isLegalMemberName(n: string): boolean

function lookupCapturedVariableValue

lookupCapturedVariableValue(func: Function, freeVariable: string, throwOnFailure: boolean): any

Given a function and a free variable name, lookupCapturedVariableValue looks up the value of that free variable in the scope chain of the provided function. If the free variable is not found, throwOnFailure indicates whether or not this function should throw or return `undefined.

function parseFunction

parseFunction(funcString: string): [, string, ParsedFunction]

function readResource

readResource(res: Resource, t: string, name: string, props: Inputs, opts: ResourceOptions): void

Reads an existing custom resource’s state from the resource monitor. Note that resources read in this way will not be part of the resulting stack’s state, as they are presumed to belong to another.

function registerResource

registerResource(res: Resource, t: string, name: string, custom: boolean, props: Inputs, opts: ResourceOptions): void

registerResource registers a new resource object with a given type t and name. It returns the auto-generated URN and the ID that will resolve after the deployment has completed. All properties will be initialized to property objects that the registration operation will resolve at the right time (or remain unresolved for deployments).

function registerResourceOutputs

registerResourceOutputs(res: Resource, outputs: Inputs): void

registerResourceOutputs completes the resource registration, attaching an optional set of computed outputs.

function resolveProperties

resolveProperties(res: Resource, resolvers: Record<string, { ... }>, t: string, name: string, allProps: any): void

resolveProperties takes as input a gRPC serialized and resolves all of the resource’s matching properties to the values inside.

NOTE: it is imperative that the properties in allProps were produced by deserializeProperties in order for output properties to work correctly w.r.t. knowns/unknowns: this function assumes that any undefined value in allPropsrepresents an unknown value that was returned by an engine operation.

function rewriteSuperReferences

rewriteSuperReferences(code: string, isStatic: boolean): string

function rpcKeepAlive

rpcKeepAlive(): { ... }

rpcKeepAlive registers a pending call to ensure that we don’t prematurely disconnect from the server. It returns a function that, when invoked, signals that the RPC has completed.

function runInPulumiStack

runInPulumiStack(init: { ... }): void

runInPulumiStack creates a new Pulumi stack resource and executes the callback inside of it. Any outputs returned by the callback will be stored as output properties on this resulting Stack object.

function serialize

serialize(): boolean

serialize returns true if resource operations should be serialized.

function serializeFunction

serializeFunction(func: Function, args?: SerializeFunctionArgs): Promise<SerializedFunction>

serializeFunction serializes a JavaScript function into a text form that can be loaded in another exuection context, for example as part of a function callback associated with an AWS Lambda. The function serialization captures any variables captured by the function body and serializes those values into the generated text along with the function body. This process is recursive, so that functions referenced by the body of the serialized function will themselves be serialized as well. Thid process also deeply serializes captured object values, including prototype chains and property descriptors, such that the semantics of the function when deserialized should match the original function.

There are several known limitations:

  • If a native function is captured either directly or indirectly, closure serialization will return an error.
  • Captured values will be serialized based on their values at the time that serializeFunction is called. Mutations to these values after that (but before the deserialized funtion is used) will not be observed by the deserialized function.

function serializeFunctionAsync

serializeFunctionAsync(func: Function, serialize?: undefined | { ... }): Promise<string>

function serializeProperties

serializeProperties(label: string, props: Inputs, dependentResources: Resource[]): Promise<Record<string, any>>

serializeProperties walks the props object passed in, awaiting all interior promises, creating a reasonable POJO object that can be remoted over to registerResource.

function serializeProperty

serializeProperty(ctx: string, prop: Input<any>, dependentResources: Resource[]): Promise<any>

serializeProperty serializes properties deeply. This understands how to wait on any unresolved promises, as appropriate, in addition to translating certain “special” values so that they are ready to go on the wire.

function serializeResourceProperties

serializeResourceProperties(label: string, props: Inputs, dependentResources: Resource[]): Promise<Record<string, any>>

serializeResourceProperties walks the props object passed in, awaiting all interior promises besides those for id and urn, creating a reasonable POJO object that can be remoted over to registerResource.

function setConfig

setConfig(k: string, v: string): void

setConfig sets a configuration variable.

function setRootResource

setRootResource(res: ComponentResource | undefined): void

setRootResource registers a resource that will become the default parent for all resources without explicit parents.

function transferProperties

transferProperties(onto: Resource, label: string, props: Inputs): OutputResolvers

transferProperties mutates the ‘onto’ resource so that it has Promise-valued properties for all the ‘props’ input/output props. Importantly all these promises are completely unresolved. This is because we don’t want anyone to observe the values of these properties until the rpc call to registerResource actually returns. This is because the registerResource call may actually override input values, and we only want people to see the final value.

The result of this call (beyond the stateful changes to ‘onto’) is the set of Promise resolvers that will be called post-RPC call. When the registerResource RPC call comes back, the values that the engine actualy produced will be used to resolve all the unresolved promised placed on ‘onto’.

interface CapturedPropertyChain

property infos

infos: CapturedPropertyInfo[];

interface CapturedPropertyInfo

property invoked

invoked: boolean;

property name

name: string;

interface CapturedVariables

property optional

optional: CapturedVariableMap;

property required

required: CapturedVariableMap;

property requiredPackages

requiredPackages: Set<string>;

interface Entry

Entry is the environment slot for a named lexically captured variable.

property array

array?: Entry[];

property expr

expr?: undefined | string;

property function

function?: FunctionInfo;

property json

json?: any;

property module

module?: undefined | string;

property object

object?: ObjectInfo;

property output

output?: Entry;

property promise

promise?: Entry;

interface FunctionInfo

property capturedValues

capturedValues: PropertyMap;

property code

code: string;

property env

env: PropertyMap;

property name

name: string | undefined;

property proto

proto?: Entry;

property requiredPackages

requiredPackages: Set<string>;

property usesNonLexicalThis

usesNonLexicalThis: boolean;

interface ObjectInfo

property env

env: PropertyMap;

property proto

proto?: Entry;

interface Options

Options is a bag of settings that controls the behavior of previews and deployments

property dryRun

dryRun?: undefined | false | true;

property engineAddr

engineAddr?: undefined | string;

property monitorAddr

monitorAddr?: undefined | string;

property parallel

parallel?: undefined | number;

property project

project?: undefined | string;

property stack

stack?: undefined | string;

interface ParsedFunction

property capturedVariables

capturedVariables: CapturedVariables;

property funcExprWithName

funcExprWithName?: undefined | string;

property funcExprWithoutName

funcExprWithoutName: string;

property functionDeclarationName

functionDeclarationName?: undefined | string;

property isArrowFunction

isArrowFunction: boolean;

property requiredPackages

requiredPackages: Set<string>;

property usesNonLexicalThis

usesNonLexicalThis: boolean;

interface ParsedFunctionCode

property funcExprWithName

funcExprWithName?: undefined | string;

property funcExprWithoutName

funcExprWithoutName: string;

property functionDeclarationName

functionDeclarationName?: undefined | string;

property isArrowFunction

isArrowFunction: boolean;

interface PropertyInfo

property configurable

configurable?: undefined | false | true;

property enumerable

enumerable?: undefined | false | true;

property get

get?: Entry;

property hasValue

hasValue: boolean;

property set

set?: Entry;

property writable

writable?: undefined | false | true;

interface PropertyInfoAndValue

property entry

entry: Entry;

property info

info?: PropertyInfo;

interface PropertyMap

method __@iterator

__@iterator(): IterableIterator<[, Entry, PropertyInfoAndValue]>

Returns an iterable of entries in the map.

method clear

clear(): void

method delete

delete(key: Entry): boolean

method entries

entries(): IterableIterator<[, Entry, PropertyInfoAndValue]>

Returns an iterable of key, value pairs for every entry in the map.

method forEach

forEach(callbackfn: { ... }, thisArg?: any): void

method get

get(key: Entry): PropertyInfoAndValue | undefined

method has

has(key: Entry): boolean

method keys

keys(): IterableIterator<Entry>

Returns an iterable of keys in the map

method set

set(key: Entry, value: PropertyInfoAndValue): this

method values

values(): IterableIterator<PropertyInfoAndValue>

Returns an iterable of values in the map

property Map

Map: MapConstructor;

property __@toStringTag

__@toStringTag: Map;

property size

size: number;

interface SerializeFunctionArgs

SerializeFunctionArgs are arguments used to serialize a JavaScript function

property exportName

exportName?: undefined | string;

The name to export from the module defined by the generated module text. Defaults to ‘handler’.

property serialize

serialize?: undefined | { ... };

A function to prevent serialization of certain objects captured during the serialization. Primarily used to prevent potential cycles.

interface SerializedFunction

SerializeFunction is a representation of a serialized JavaScript function.

property exportName

exportName: string;

The name of the exported module member.

property requiredPackages

requiredPackages: Set<string>;

The set of pacakges that were ‘require’d by the transitive closure of functions serialized as part of the JavaScript function serialization. These pacakges must be able to resolve in the target execution environment for the serialized function to be able to be loaded and evaluated correctly.

property text

text: string;

The text of a JavaScript module which exports a single name bound to a function value matching the serialized JavaScript function.

let excessiveDebugOutput

let excessiveDebugOutput: boolean = false;

excessiveDebugOutput enables, well, pretty excessive debug output pertaining to resources and properties.

type CapturedVariableMap

type CapturedVariableMap = Map<string, CapturedPropertyChain[]>;

type OutputResolvers

type OutputResolvers = Record<string, { ... }>;