Node Class
Represents the construct node in the scope tree.
Example
// Install: dotnet add package Constructs
using Constructs;
var node = new Node(host, scope, id);
// Install: go get github.com/aws/constructs-go/constructs/v10
import "github.com/aws/constructs-go/constructs/v10"
node := constructs.NewNode(host, scope, id)
Initializer
new Node(host: Construct, scope: IConstruct, id: string)
Node(host: Construct, scope: IConstruct, id: str)
new Node(Construct host, IConstruct scope, String id)
new Node(Construct host, IConstruct scope, string id)
NewNode(Host Construct, Scope IConstruct, Id *string)
Properties
notes · example
The address is a 42 character string: the prefix "c8" followed by 40 lowercase hexadecimal characters (0-9a-f). It is a SHA-1 over the ids of the constructs on the path from the root of the tree down to this construct.
To enable refactoring of construct trees, constructs with the ID Default are excluded from the calculation. Within a tree, a/Default/b and a/b have the same address.
This means the address is not guaranteed to identify a construct uniquely:
- Any construct whose path is made up of the same ids has the same address. Two trees that are shaped alike therefore hand out the same addresses.
- As described above, a construct under a
Defaultscope has the same address as its counterpart outside of that scope. - The digest is of fixed width, so even distinct paths can in principle hash to the same address. SHA-1 in particular is no longer collision resistant.
Use an address to derive stable, deterministic names from the location of a construct in the tree. Do not use it as the identity of a construct: instead, compare construct instances or use the path.
c83a2846e506bcc5f10682b564084bca2d275709ee
childrenIConstruct[]childrentyping.List[IConstruct]childrenList<IConstruct>ChildrenIConstruct[]Children*[]IConstruct#defaultChildmay be undefinedIConstructdefault_childmay be undefinedIConstructdefaultChildmay be undefinedIConstructDefaultChildmay be undefinedIConstructDefaultChildmay be undefinedIConstruct#notes
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.
dependenciesIConstruct[]dependenciestyping.List[IConstruct]dependenciesList<IConstruct>DependenciesIConstruct[]Dependencies*[]IConstruct#This expands the sets of Dependables to the set of Constructs that they represent.
This is a scope-unique id. To obtain an id that reflects the full location of this construct in the tree, use path or addr.
metadataMetadataEntry[]metadatatyping.List[MetadataEntry]metadataList<MetadataEntry>MetadataMetadataEntry[]Metadata*[]MetadataEntry#This can be used, for example, to implement support for deprecation notices, source mapping, etc.
Components are separated by '/'.
scopemay be undefinedIConstructscopemay be undefinedIConstructscopemay be undefinedIConstructScopemay be undefinedIConstructScopemay be undefinedIConstruct#The value is undefined at the root of the construct scope tree.
scopesIConstruct[]scopestyping.List[IConstruct]scopesList<IConstruct>ScopesIConstruct[]Scopes*[]IConstruct#Methods
addDependency(...deps: IDependable[]): voiddef add_dependency(self, deps: IDependable) -> Nonepublic void addDependency(IDependable deps)public void AddDependency(IDependable deps)func AddDependency(Deps IDependable)#notes
It is up to the target document language to decide what an ordering relationship means and how it should be rendered; for example, in the AWS CDK for CloudFormation it means a dependency from every resource in scope of the current construct to every resource in scope of the target set of constructs, that get realized as either stack dependencies or DependsOn relationships in the synthesized template.
IDependable is a marker interface that indicates that a class has used Dependable.implement() to implement the IDependable interface. It can be used to make the target object represent more than one set of constructs at a time. For example, a DependencyGroup uses this interface to represent an explicit list of 0 or more constructs that should be involved in the dependency relationship.
addMetadata(type: string, data: any, options?: MetadataOptions): voiddef add_metadata(self, type: str, data: Any, options: typing.Optional[MetadataOptions] = None) -> Nonepublic void addMetadata(String type, Object data, MetadataOptions options)public void AddMetadata(string type, object data, MetadataOptions? options = null)func AddMetadata(Type *string, Data interface{}, Options MetadataOptions)#notes · 3 parameters
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. Note that construct metadata is not the same as CloudFormation resource metadata and is never written to the CloudFormation template. The metadata entries are written to the Cloud Assembly Manifest if the treeMetadata property is specified in the props of the App that contains this Construct.
Parameters
typetypetypetypeType— a string denoting the type of metadata.datadatadatadataData— the value of the metadata (can be a Token).optionsoptionsoptionsoptionsOptions— options.
addValidation(validation: IValidation): voiddef add_validation(self, validation: IValidation) -> Nonepublic void addValidation(IValidation validation)public void AddValidation(IValidation validation)func AddValidation(Validation IValidation)#When node.validate() is called, the validate() method will be called on all validations and all errors will be returned.
1 parameter
Parameters
validationvalidationvalidationvalidationValidation— The validation object.
findAll(order?: ConstructOrder): IConstruct[]def find_all(self, order: typing.Optional[ConstructOrder] = None) -> typing.List[IConstruct]public List<IConstruct> findAll(ConstructOrder order)public IConstruct[] FindAll(ConstructOrder? order = null)func FindAll(Order ConstructOrder) *[]IConstruct#findChild(id: string): IConstructdef find_child(self, id: str) -> IConstructpublic IConstruct findChild(String id)public IConstruct FindChild(string id)func FindChild(Id *string) IConstruct#Throws an error if the child is not found.
1 parameter · returns
Parameters
ididididId— Identifier of direct child.
Returns: Child with the given id.
getAllContext(defaults?: json): anydef get_all_context(self, defaults: typing.Optional[Any] = None) -> Anypublic Object getAllContext(Object defaults)public object GetAllContext(object? defaults = null)func GetAllContext(Defaults interface{}) interface{}#Context is usually initialized at the root, but can be overridden at any point in the tree.
1 parameter · returns
Parameters
defaultsdefaultsdefaultsdefaultsDefaults— Any keys to override the retrieved context.
Returns: The context object or an empty object if there is discovered context
getContext(key: string): anydef get_context(self, key: str) -> Anypublic Object getContext(String key)public object GetContext(string key)func GetContext(Key *string) interface{}#Context is usually initialized at the root, but can be overridden at any point in the tree.
1 parameter · returns
Parameters
keykeykeykeyKey— The context key.
Returns: The context value or throws error if there is no context value for this key
After this call, no more children can be added to this construct or to any children.
of(construct: IConstruct): Node // chainable@staticmethod def of(construct: IConstruct) -> Nodepublic static Node of(IConstruct construct)public static Node Of(IConstruct construct)func Of(Construct IConstruct) Nodestaticdeprecated#1 parameter
Parameters
constructconstructconstructconstructConstruct— the construct.
removeDependency(...deps: IDependable[]): voiddef remove_dependency(self, deps: IDependable) -> Nonepublic void removeDependency(IDependable deps)public void RemoveDependency(IDependable deps)func RemoveDependency(Deps IDependable)#This removes any dependency added using node.addDependency(). It must use the exact same object that was involved in the addDependency() call.
setContext(key: string, value: any): voiddef set_context(self, key: str, value: Any) -> Nonepublic void setContext(String key, Object value)public void SetContext(string key, object value)func SetContext(Key *string, Value interface{})#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.
2 parameters
Parameters
keykeykeykeyKey— The context key.valuevaluevaluevalueValue— The context value.
tryFindChild(id: string): IConstructdef try_find_child(self, id: str) -> IConstructpublic IConstruct tryFindChild(String id)public IConstruct TryFindChild(string id)func TryFindChild(Id *string) IConstruct#1 parameter · returns
Parameters
ididididId— Identifier of direct child.
Returns: the child if found, or undefined
tryGetContext(key: string): anydef try_get_context(self, key: str) -> Anypublic Object tryGetContext(String key)public object TryGetContext(string key)func TryGetContext(Key *string) interface{}#Context is usually initialized at the root, but can be overridden at any point in the tree.
1 parameter · returns
Parameters
keykeykeykeyKey— The context key.
Returns: The context value or undefined if there is no context value for this key.
tryRemoveChild(childName: string): booleandef try_remove_child(self, child_name: str) -> boolpublic Boolean tryRemoveChild(String childName)public bool TryRemoveChild(string childName)func TryRemoveChild(ChildName *string) *bool#returns
Returns: Whether a child with the given name was deleted.
validate(): string[]def validate(self, ) -> typing.List[str]public List<String> validate()public string[] Validate()func Validate() *[]*string#Invokes the validate() method on all validations added through addValidation().
returns
Returns: an array of validation error messages associated with this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.
1 parameter · returns
Parameters
mixinsmixinsmixinsmixinsMixins— The mixins to apply.
Returns: This construct for chaining