Skip to main content
Construct is the base class for all elements in the tfts construct tree.

Constructor

new Construct(scope: Construct, id: string)

Properties

node

readonly node: Node The tree node for this construct.

Node Class Methods

The node property provides access to the following methods:

setContext()

setContext(key: string, value: any): void
Sets a context value for this node and its children.

getContext()

getContext(key: string): any
Gets a context value from this node or its parents.

tryGetContext()

tryGetContext(key: string): any
Tries to get a context value, returning undefined if not found.

findAll()

findAll(): IConstruct[]
Returns all children of this node.

findChild()

findChild(id: string): IConstruct
Finds a child by its ID. Throws if not found.

tryFindChild()

tryFindChild(id: string): IConstruct | undefined
Tries to find a child by its ID.

addMetadata()

addMetadata(type: string, data: any): void
Adds metadata to the construct.

addValidation()

addValidation(validation: IValidation): void
Adds a validation to the construct.

validate()

validate(): string[]
Runs all validations on the construct and returns a list of errors.