Pulumi's Node.js SDK for infrastructure-as-code platform that allows you to create, deploy, and manage infrastructure using familiar programming languages and tools.
npx @tessl/cli install tessl/npm-pulumi--pulumi@3.193.0Pulumi's Node.js SDK is a comprehensive infrastructure-as-code platform that enables developers to define, deploy, and manage cloud infrastructure using TypeScript and JavaScript. The SDK provides a declarative resource model with support for major cloud providers including AWS, Azure, Google Cloud Platform, and Kubernetes, featuring strongly-typed APIs, automatic dependency management, and state management.
npm install @pulumi/pulumiimport * as pulumi from "@pulumi/pulumi";Import specific components:
import { Config, Output, Resource, ComponentResource } from "@pulumi/pulumi";For CommonJS:
const pulumi = require("@pulumi/pulumi");
const { Config, Output, Resource } = require("@pulumi/pulumi");import * as pulumi from "@pulumi/pulumi";
// Configuration management
const config = new pulumi.Config();
const name = config.get("name") || "world";
// Resource creation with outputs
const bucket = new aws.s3.Bucket("my-bucket", {
website: {
indexDocument: "index.html",
},
});
// Export stack outputs
export const bucketName = bucket.id;
export const websiteUrl = pulumi.interpolate`http://${bucket.websiteEndpoint}`;Pulumi's Node.js SDK is built around several key components:
Secure configuration and secrets management for different environments and stacks. Supports both plain text and encrypted secret values.
class Config {
constructor(name?: string);
get<K>(key: string, opts?: StringConfigOptions<K>): K | undefined;
getSecret<K>(key: string, opts?: StringConfigOptions<K>): Output<K | undefined>;
require<K>(key: string, opts?: StringConfigOptions<K>): K;
requireSecret<K>(key: string, opts?: StringConfigOptions<K>): Output<K>;
getBoolean(key: string): boolean | undefined;
getNumber(key: string, opts?: NumberConfigOptions): number | undefined;
getObject<T>(key: string): T | undefined;
}Async value management with dependency tracking for handling promises and resource dependencies throughout your infrastructure code.
class Output<T> {
apply<U>(func: (t: T) => Input<U>): Output<U>;
isKnown: Promise<boolean>;
isSecret: Promise<boolean>;
}
function output<T>(val: Input<T>): Output<Unwrap<T>>;
function secret<T>(val: Input<T>): Output<Unwrap<T>>;
function all<T>(values: T): Output<UnwrappedObject<T>>;
function interpolate(literals: TemplateStringsArray, ...placeholders: Input<any>[]): Output<string>;
type Input<T> = T | Promise<T> | OutputInstance<T>;Core infrastructure resource management with lifecycle management, dependency tracking, and provider integration.
abstract class Resource {
readonly urn: Output<string>;
protected constructor(type: string, name: string, opts?: ResourceOptions);
}
class CustomResource extends Resource {
readonly id: Output<ID>;
protected constructor(type: string, name: string, props?: any, opts?: CustomResourceOptions);
}
class ComponentResource<TData = any> extends Resource {
protected constructor(type: string, name: string, opts?: ComponentResourceOptions);
registerOutputs(outputs?: Inputs | Promise<Inputs> | Output<Inputs>): void;
}
interface ResourceOptions {
dependsOn?: Input<Input<Resource>[]> | Input<Resource>;
protect?: boolean;
parent?: Resource;
provider?: ProviderResource;
version?: string;
}Access outputs from other Pulumi stacks for cross-stack dependencies and data sharing.
class StackReference extends CustomResource {
constructor(name: string, args: StackReferenceArgs, opts?: CustomResourceOptions);
getOutput(name: Input<string>): Output<any>;
requireOutput(name: Input<string>): Output<any>;
readonly outputs: Output<{[name: string]: any}>;
readonly secretOutputNames: Output<string[]>;
}File and archive management for deploying code, configurations, and other artifacts to cloud resources.
abstract class Asset {}
abstract class Archive {}
class FileAsset extends Asset {
constructor(path: string);
}
class StringAsset extends Asset {
constructor(text: string);
}
class FileArchive extends Archive {
constructor(path: string);
}
class AssetArchive extends Archive {
constructor(assets: AssetMap);
}
type AssetMap = {[name: string]: Asset | Archive};Programmatic stack and workspace management for building deployment tooling and CI/CD integration.
class LocalWorkspace {
static create(args?: LocalWorkspaceOptions): Promise<LocalWorkspace>;
static createStack(args: LocalProgramArgs): Promise<Stack>;
static selectStack(args: LocalProgramArgs): Promise<Stack>;
}
class Stack {
constructor(name: string, workspace: Workspace);
up(opts?: UpOptions): Promise<UpResult>;
preview(opts?: PreviewOptions): Promise<PreviewResult>;
destroy(opts?: DestroyOptions): Promise<DestroyResult>;
refresh(opts?: RefreshOptions): Promise<RefreshResult>;
}Create custom resource providers in TypeScript/JavaScript for managing resources not supported by existing providers.
class dynamic.Resource extends CustomResource {
constructor(
provider: ResourceProvider<Inputs, Outputs>,
name: string,
props: Inputs,
opts?: CustomResourceOptions
);
}
interface ResourceProvider<Inputs, Outputs> {
create?(inputs: Inputs): Promise<CreateResult<Outputs>>;
read?(id: string, props?: any): Promise<ReadResult<Outputs>>;
update?(id: string, olds: Outputs, news: Inputs): Promise<UpdateResult<Outputs>>;
delete?(id: string, props: Outputs): Promise<void>;
}Build and maintain custom Pulumi resource providers for new cloud services and infrastructure platforms.
interface Provider {
check?(urn: string, olds: any, news: any): Promise<CheckResult>;
create?(urn: string, inputs: any): Promise<CreateResult>;
read?(id: string, urn: string, props?: any): Promise<ReadResult>;
update?(id: string, urn: string, olds: any, news: any): Promise<UpdateResult>;
delete?(id: string, urn: string, props: any): Promise<void>;
construct?(name: string, type: string, inputs: any, options: any): Promise<ConstructResult>;
invoke?(token: string, inputs: any): Promise<InvokeResult>;
}
function main(provider: Provider, args?: string[]): Promise<void>;Low-level runtime functions for resource registration, serialization, and state management.
function registerResource(
res: Resource,
type: string,
name: string,
props: Inputs,
opts?: ResourceOptions
): Promise<void>;
function invoke(
token: string,
props: Inputs,
opts?: InvokeOptions
): Promise<any>;
function invokeOutput(
token: string,
props: Inputs,
opts?: InvokeOutputOptions
): Output<any>;Structured logging and error handling for infrastructure deployment diagnostics.
function debug(msg: string, resource?: Resource): void;
function info(msg: string, resource?: Resource): void;
function warn(msg: string, resource?: Resource): void;
function error(msg: string, resource?: Resource): void;
class RunError extends Error {}
class ResourceError extends Error {
constructor(message: string, resource: Resource | undefined, hideStack?: boolean);
}Helper functions and utilities for common operations in Pulumi programs.
function isInstance<T>(obj: any, name: string): obj is T;
function hasTrueBooleanMember(obj: any, memberName: string): boolean;
function values(obj: any): any[];
function getOrganization(): string;
function getProject(): string;
function getStack(): string;
function getRootDirectory(): string;Pulumi provides structured error types for different failure scenarios:
class RunError extends Error {}
class ResourceError extends Error {
constructor(message: string, resource: Resource | undefined, hideStack?: boolean);
}
class InputPropertyError extends Error {
propertyPath: string;
reason: string;
}
class InputPropertiesError extends Error {
properties: string[];
reasons: string[];
}type Input<T> = T | Promise<T> | OutputInstance<T>;
type Inputs = Record<string, Input<any>>;
type ID = string;
type URN = string;
type Unwrap<T> = T extends OutputInstance<infer U> ? U :
T extends Promise<infer U> ? U :
T;
type Lifted<T> = {
[K in keyof T]: Output<T[K]>;
};