Class ConstructNode
Represents the construct node in the scope tree.
public class ConstructNode : DeputyBase
- Inheritance
-
ConstructNode
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
Construct construct;
var constructNode = new ConstructNode(construct, construct, "id");
Remarks
ExampleMetadata: fixture=_generated
Constructors
ConstructNode(Construct, IConstruct, string)
public ConstructNode(Construct host, IConstruct scope, string id)
Parameters
host
Constructscope
IConstructid
string
Properties
Addr
Returns an opaque tree-unique address for this construct.
public virtual string Addr { get; }
Property Value
Remarks
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 value: c83a2846e506bcc5f10682b564084bca2d275709ee
Children
All direct children of this construct.
public virtual IConstruct[] Children { get; }
Property Value
DefaultChild
Returns the child construct that has the id Default
or Resource"
.
public virtual IConstruct? DefaultChild { get; set; }
Property Value
- IConstruct
a construct or undefined if there is no default child
Remarks
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.
Throws: if there is more than one child
Dependencies
Return all dependencies registered on this node or any of its children.
public virtual IDependency[] Dependencies { get; }
Property Value
Id
The id of this construct within the current scope.
public virtual string Id { get; }
Property Value
Remarks
This is a a scope-unique id. To obtain an app-unique id for this construct, use uniqueId
.
Locked
Returns true if this construct or the scopes in which it is defined are locked.
public virtual bool Locked { get; }
Property Value
Metadata
(deprecated) DEPRECATED.
[Obsolete("use `metadataEntry`")]
public virtual IMetadataEntry[] Metadata { get; }
Property Value
- IMetadataEntry[]
Remarks
Stability: Deprecated
MetadataEntry
An immutable array of metadata objects associated with this construct.
public virtual IMetadataEntry[] MetadataEntry { get; }
Property Value
- IMetadataEntry[]
Remarks
This can be used, for example, to implement support for deprecation notices, source mapping, etc.
PATH_SEP
Separator used to delimit construct path components.
public static string PATH_SEP { get; }
Property Value
Path
The full, absolute path of this construct in the tree.
public virtual string Path { get; }
Property Value
Remarks
Components are separated by '/'.
Root
public virtual IConstruct Root { get; }
Property Value
- IConstruct
The root of the construct tree.
Scope
Returns the scope in which this construct is defined.
public virtual IConstruct? Scope { get; }
Property Value
Remarks
The value is undefined
at the root of the construct scope tree.
Scopes
All parent scopes of this construct.
public virtual IConstruct[] Scopes { get; }
Property Value
- IConstruct[]
a list of parent scopes. The last element in the list will always be the current construct and the first element will be the root of the tree.
UniqueId
(deprecated) A tree-global unique alphanumeric identifier for this construct.
[Obsolete("use `node.addr` to obtain a consistent 42 character address for this node (see https://github.com/aws/constructs/pull/314). Alternatively, to get a CloudFormation-compatible unique identifier, use `Names.uniqueId()`.")]
public virtual string UniqueId { get; }
Property Value
Remarks
Includes all components of the tree.
Stability: Deprecated
Methods
AddDependency(params IDependable[])
Add an ordering dependency on another Construct.
public virtual void AddDependency(params IDependable[] dependencies)
Parameters
dependencies
IDependable[]
Remarks
All constructs in the dependency's scope will be deployed before any construct in this construct's scope.
AddError(string)
(deprecated) DEPRECATED: Adds an { "error": <message> } metadata entry to this construct.
[Obsolete("use `Annotations.of(construct).addError()`")]
public virtual void AddError(string message)
Parameters
message
stringThe error message.
Remarks
The toolkit will fail synthesis when errors are reported.
Stability: Deprecated
AddInfo(string)
(deprecated) DEPRECATED: Adds a { "info": <message> } metadata entry to this construct.
[Obsolete("use `Annotations.of(construct).addInfo()`")]
public virtual void AddInfo(string message)
Parameters
message
stringThe info message.
Remarks
The toolkit will display the info message when apps are synthesized.
Stability: Deprecated
AddMetadata(string, object, object?)
Adds a metadata entry to this construct.
public virtual void AddMetadata(string type, object data, object? fromFunction = null)
Parameters
type
stringa string denoting the type of metadata.
data
objectthe value of the metadata (can be a Token).
fromFunction
objecta function under which to restrict the metadata entry's stack trace (defaults to this.addMetadata).
Remarks
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.
AddValidation(IValidation)
Add a validator to this construct Node.
public virtual void AddValidation(IValidation validation)
Parameters
validation
IValidation
AddWarning(string)
(deprecated) DEPRECATED: Adds a { "warning": <message> } metadata entry to this construct.
[Obsolete("use `Annotations.of(construct).addWarning()`")]
public virtual void AddWarning(string message)
Parameters
message
stringThe warning message.
Remarks
The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.
Stability: Deprecated
ApplyAspect(IAspect)
(deprecated) DEPRECATED: Applies the aspect to this Constructs node.
[Obsolete("This API is going to be removed in the next major version of the AWS CDK. Please use `Aspects.of(scope).add()` instead.")]
public virtual void ApplyAspect(IAspect aspect)
Parameters
aspect
IAspect
Remarks
Stability: Deprecated
FindAll(ConstructOrder?)
Return this construct and all of its children in the given order.
public virtual IConstruct[] FindAll(ConstructOrder? order = null)
Parameters
order
ConstructOrder?
Returns
FindChild(string)
Return a direct child by id.
public virtual IConstruct FindChild(string id)
Parameters
id
stringIdentifier of direct child.
Returns
- IConstruct
Child with the given id.
Remarks
Throws an error if the child is not found.
Prepare(ConstructNode)
(deprecated) Invokes "prepare" on all constructs (depth-first, post-order) in the tree under node
.
[Obsolete("Use `app.synth()` instead")]
public static void Prepare(ConstructNode node)
Parameters
node
ConstructNodeThe root node.
Remarks
Stability: Deprecated
SetContext(string, object)
This can be used to set contextual values.
public virtual void SetContext(string key, object value)
Parameters
Remarks
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.
Synth(ConstructNode, ISynthesisOptions?)
(deprecated) Synthesizes a CloudAssembly from a construct tree.
[Obsolete("Use `app.synth()` or `stage.synth()` instead")]
public static CloudAssembly Synth(ConstructNode node, ISynthesisOptions? options = null)
Parameters
node
ConstructNodeThe root of the construct tree.
options
ISynthesisOptionsSynthesis options.
Returns
- CloudAssembly
Remarks
Stability: Deprecated
TryFindChild(string)
Return a direct child by id, or undefined.
public virtual IConstruct? TryFindChild(string id)
Parameters
id
stringIdentifier of direct child.
Returns
- IConstruct
the child if found, or undefined
TryGetContext(string)
Retrieves a value from tree context.
public virtual object TryGetContext(string key)
Parameters
key
stringThe context key.
Returns
- object
The context value or
undefined
if there is no context value for the key.
Remarks
Context is usually initialized at the root, but can be overridden at any point in the tree.
TryRemoveChild(string)
Remove the child with the given name, if present.
public virtual bool TryRemoveChild(string childName)
Parameters
childName
string
Returns
- bool
Whether a child with the given name was deleted.
Validate(ConstructNode)
Invokes "validate" on all constructs in the tree (depth-first, pre-order) and returns the list of all errors.
public static IValidationError[] Validate(ConstructNode node)
Parameters
node
ConstructNodeThe root node.
Returns
Remarks
An empty list indicates that there are no errors.