API Reference
Classes 
Node 
The internal node of a construct.
Methods 
| Name | Description | 
|---|---|
 | Adds a connection between two constructs. | 
 | Add an ordering dependency on another construct. | 
 | Adds a metadata entry to this construct. | 
 | Adds a validation to this construct. | 
 | Return this construct and all of its children in the given order. | 
 | Return a direct child by id. | 
 | Retrieves a value from tree context if present. Otherwise, would throw an error. | 
 | Locks this construct from allowing more children to be added. | 
 | This can be used to set contextual values. | 
 | Return a direct child by id, or undefined. | 
 | Retrieves a value from tree context. | 
 | Remove the child with the given name, if present. | 
 | Validates this construct. | 
addConnection 
addConnection(props: AddConnectionProps): void
Adds a connection between two constructs.
A connection is a piece of metadata describing how one construct is related to another construct.
propsRequired 
- Type: AddConnectionProps
 
addDependency 
addDependency(...deps: Array<IDependable>): void
Add an ordering dependency on another construct.
An IDependable
depsRequired 
- Type: constructs.IDependable
 
addMetadata 
addMetadata(type: str, data: any, options?: MetadataOptions): void
Adds a metadata entry to this construct.
Entries are arbitrary values and will also include a stack trace to allow tracing back to the code location for when the entry was added. It can be used, for example, to include source mapping in CloudFormation templates to improve diagnostics.
typeRequired 
- Type: str
 
a string denoting the type of metadata.
dataRequired 
- Type: any
 
the value of the metadata (can be a Token).
If null/undefined, metadata will not be added.
optionsOptional 
- Type: constructs.MetadataOptions
 
options.
addValidation 
addValidation(validation: IValidation): void
Adds a validation to this construct.
When node.validate() is called, the validate() method will be called on
all validations and all errors will be returned.
validationRequired 
- Type: constructs.IValidation
 
The validation object.
findAll 
findAll(order?: ConstructOrder): MutArray<IConstruct>
Return this construct and all of its children in the given order.
orderOptional 
- Type: constructs.ConstructOrder
 
findChild 
findChild(): IConstruct
Return a direct child by id.
Throws an error if the child is not found.
getContext 
getContext(key: str): any
Retrieves a value from tree context if present. Otherwise, would throw an error.
Context is usually initialized at the root, but can be overridden at any point in the tree.
keyRequired 
- Type: str
 
The context key.
lock 
lock(): void
Locks this construct from allowing more children to be added.
After this call, no more children can be added to this construct or to any children.
setContext 
setContext(key: str, value: any): void
This can be used to set contextual values.
Context must be set before any children are added, since children may consult context info during construction. If the key already exists, it will be overridden.
keyRequired 
- Type: str
 
The context key.
valueRequired 
- Type: any
 
The context value.
tryFindChild 
tryFindChild(): IConstruct?
Return a direct child by id, or undefined.
tryGetContext 
tryGetContext(key: str): any
Retrieves a value from tree context.
Context is usually initialized at the root, but can be overridden at any point in the tree.
keyRequired 
- Type: str
 
The context key.
tryRemoveChild 
tryRemoveChild(childName: str): bool
Remove the child with the given name, if present.
childNameRequired 
- Type: str
 
validate 
validate(): MutArray<str>
Validates this construct.
Invokes the validate() method on all validations added through
addValidation().
Properties 
| Name | Type | Description | 
|---|---|---|
 | str | Returns an opaque tree-unique address for this construct. | 
 |  | Returns the root of the construct tree (the cloud.App object). | 
 | MutArray<constructs.IConstruct> | All direct children of this construct. | 
 | MutArray<constructs.IConstruct> | Return all dependencies registered on this node (non-recursive). | 
 | str | The id of this construct within the current scope. | 
 | bool | Returns true if this construct or the scopes in which it is defined are locked. | 
 | MutArray<constructs.MetadataEntry> | An immutable array of metadata objects associated with this construct. | 
 | str | The full, absolute path of this construct in the tree. | 
 | constructs.IConstruct | Returns the root of the construct tree (the cloud.App object). | 
 | MutArray<constructs.IConstruct> | All parent scopes of this construct. | 
 | constructs.IConstruct | Returns the scope in which this construct is defined. | 
 | str | The color of the construct for display purposes. | 
 | constructs.IConstruct | Returns the child construct that has the id Default or Resource". | 
 | str | Description of the construct for display purposes. | 
 | bool | Whether the node is expanded or collapsed by default in the UI. | 
 | bool | Whether the construct should be hidden by default in tree visualizations. | 
 | str | The icon of the construct for display purposes. | 
 | str | The source file or library where the construct was defined. | 
 | str | Title of the construct for display purposes. | 
addrRequired 
addr: str;
- Type: str
 
Returns an opaque tree-unique address for this construct.
Addresses are 42 characters hexadecimal strings. They begin with "c8" followed by 40 lowercase hexadecimal characters (0-9a-f).
Addresses are calculated using a SHA-1 of the components of the construct path.
To enable refactorings of construct trees, constructs with the ID Default
will be excluded from the calculation. In those cases constructs in the
same tree may have the same addreess.
Example
c83a2846e506bcc5f10682b564084bca2d275709ee
appRequired 
app: IApp;
- Type: IApp
 
Returns the root of the construct tree (the cloud.App object).
Similar to root.
childrenRequired 
children: MutArray<IConstruct>;
- Type: MutArray<constructs.IConstruct>
 
All direct children of this construct.
dependenciesRequired 
dependencies: MutArray<IConstruct>;
- Type: MutArray<constructs.IConstruct>
 
Return all dependencies registered on this node (non-recursive).
idRequired 
id: str;
- Type: str
 
The id of this construct within the current scope.
This is a a scope-unique id. To obtain an app-unique id for this construct, use addr.
lockedRequired 
locked: bool;
- Type: bool
 
Returns true if this construct or the scopes in which it is defined are locked.
metadataRequired 
metadata: MutArray<MetadataEntry>;
- Type: MutArray<constructs.MetadataEntry>
 
An immutable array of metadata objects associated with this construct.
This can be used, for example, to implement support for deprecation notices, source mapping, etc.
pathRequired 
path: str;
- Type: str
 
The full, absolute path of this construct in the tree.
Components are separated by '/'.
rootRequired 
root: IConstruct;
- Type: constructs.IConstruct
 
Returns the root of the construct tree (the cloud.App object).
Similar to app.
scopesRequired 
scopes: MutArray<IConstruct>;
- Type: MutArray<constructs.IConstruct>
 
All parent scopes of this construct.
scopeOptional 
scope: IConstruct;
- Type: constructs.IConstruct
 
Returns the scope in which this construct is defined.
The value is undefined at the root of the construct scope tree.
colorOptional 
color: str;
- Type: str
 
The color of the construct for display purposes.
Supported colors are:
- orange
 - sky
 - emerald
 - lime
 - pink
 - amber
 - cyan
 - purple
 - red
 - violet
 - slate
 
defaultChildOptional 
defaultChild: IConstruct;
- Type: constructs.IConstruct
 
Returns the child construct that has the id Default or Resource".
This is usually the construct that provides the bulk of the underlying functionality. Useful for modifications of the underlying construct that are not available at the higher levels. Override the defaultChild property.
This should only be used in the cases where the correct default child is not named 'Resource' or 'Default' as it should be.
If you set this to undefined, the default behavior of finding the child named 'Resource' or 'Default' will be used.
descriptionOptional 
description: str;
- Type: str
 
Description of the construct for display purposes.
expandedOptional 
expanded: bool;
- Type: bool
 - Default: false
 
Whether the node is expanded or collapsed by default in the UI.
By default, nodes are collapsed. Set this to true if you want the node to be expanded by default.
hiddenOptional 
hidden: bool;
- Type: bool
 
Whether the construct should be hidden by default in tree visualizations.
iconOptional 
icon: str;
- Type: str
 
The icon of the construct for display purposes.
Supported icons are from Heroicons:
- https://heroicons.com/ e.g.
 - "academic-cap"
 
sourceModuleOptional 
sourceModule: str;
- Type: str
 
The source file or library where the construct was defined.
titleOptional 
title: str;
- Type: str
 
Title of the construct for display purposes.
Structs 
AddConnectionProps 
Props for Node.addConnection.
Initializer 
let AddConnectionProps = AddConnectionProps{ ... };
Properties 
| Name | Type | Description | 
|---|---|---|
 | str | A name for the connection. | 
 | constructs.IConstruct | The target of the connection. | 
 | constructs.IConstruct | The source of the connection. | 
 | str | An operation that the source construct supports. | 
 | str | An operation that the target construct supports. | 
nameRequired 
name: str;
- Type: str
 
A name for the connection.
targetRequired 
target: IConstruct;
- Type: constructs.IConstruct
 
The target of the connection.
sourceOptional 
source: IConstruct;
- Type: constructs.IConstruct
 - Default: this
 
The source of the connection.
sourceOpOptional 
sourceOp: str;
- Type: str
 - Default: no operation
 
An operation that the source construct supports.
targetOpOptional 
targetOp: str;
- Type: str
 - Default: no operation
 
An operation that the target construct supports.
Protocols 
IApp 
Represents a Wing application.
Methods 
| Name | Description | 
|---|---|
 | Generate a unique ID for the given scope and prefix. | 
makeId 
makeId(prefix?: str): str
Generate a unique ID for the given scope and prefix.
The newly generated ID is guaranteed to be unique within the given scope. It will have the form '{prefix}{n}', where '{prefix}' is the given prefix and '{n}' is an ascending sequence of integers starting from '0'.
prefixOptional 
- Type: str
 
prepended to the unique identifier.
Properties 
| Name | Type | Description | 
|---|---|---|
 | constructs.Node | The tree node. | 
 | str | The directory of the entrypoint of the current Wing application. | 
 | bool | true if this is a testing environment. | 
 |  | The application's parameter registrar. | 
 | str | The .wing directory into which you can emit intermediate artifacts during preflight. | 
nodeRequired 
node: Node;
- Type: constructs.Node
 
The tree node.
entrypointDirRequired 
entrypointDir: str;
- Type: str
 
The directory of the entrypoint of the current Wing application.
isTestEnvironmentRequired 
isTestEnvironment: bool;
- Type: bool
 
true if this is a testing environment.
parametersRequired 
parameters: ParameterRegistrar;
- Type: ParameterRegistrar
 
The application's parameter registrar.
workdirRequired 
workdir: str;
- Type: str
 
The .wing directory into which you can emit intermediate artifacts during preflight.