ConstructNode
- class aws_cdk.core.ConstructNode(host, scope, id)
Bases:
object
Represents the construct node in the scope tree.
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.core as cdk # construct: cdk.Construct construct_node = cdk.ConstructNode(construct, construct, "id")
- Parameters:
host (
Construct
) –scope (
IConstruct
) –id (
str
) –
Methods
- add_dependency(*dependencies)
Add an ordering dependency on another Construct.
All constructs in the dependency’s scope will be deployed before any construct in this construct’s scope.
- Parameters:
dependencies (
IDependable
) –- Return type:
None
- add_error(message)
(deprecated) DEPRECATED: Adds an { “error”: } metadata entry to this construct.
The toolkit will fail synthesis when errors are reported.
- Parameters:
message (
str
) – The error message.- Deprecated:
use
Annotations.of(construct).addError()
- Stability:
deprecated
- Return type:
None
- add_info(message)
(deprecated) DEPRECATED: Adds a { “info”: } metadata entry to this construct.
The toolkit will display the info message when apps are synthesized.
- Parameters:
message (
str
) – The info message.- Deprecated:
use
Annotations.of(construct).addInfo()
- Stability:
deprecated
- Return type:
None
- add_metadata(type, data, from_function=None)
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.
- Parameters:
type (
str
) – a string denoting the type of metadata.data (
Any
) – the value of the metadata (can be a Token). If null/undefined, metadata will not be added.from_function (
Optional
[Any
]) – a function under which to restrict the metadata entry’s stack trace (defaults to this.addMetadata).
- Return type:
None
- add_validation(validation)
Add a validator to this construct Node.
- Parameters:
validation (
IValidation
) –- Return type:
None
- add_warning(message)
(deprecated) DEPRECATED: Adds a { “warning”: } metadata entry to this construct.
The toolkit will display the warning when an app is synthesized, or fail if run in –strict mode.
- Parameters:
message (
str
) – The warning message.- Deprecated:
use
Annotations.of(construct).addWarning()
- Stability:
deprecated
- Return type:
None
- apply_aspect(aspect)
(deprecated) DEPRECATED: Applies the aspect to this Constructs node.
- Parameters:
aspect (
IAspect
) –- Deprecated:
- Return type:
None
This API is going to be removed in the next major version of the AWS CDK. Please use
Aspects.of(scope).add()
instead.- Stability:
deprecated
- find_all(order=None)
Return this construct and all of its children in the given order.
- Parameters:
order (
Optional
[ConstructOrder
]) –- Return type:
List
[IConstruct
]
- find_child(id)
Return a direct child by id.
Throws an error if the child is not found.
- Parameters:
id (
str
) – Identifier of direct child.- Return type:
- Returns:
Child with the given id.
- set_context(key, value)
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.
- Parameters:
key (
str
) – The context key.value (
Any
) – The context value.
- Return type:
None
- try_find_child(id)
Return a direct child by id, or undefined.
- Parameters:
id (
str
) – Identifier of direct child.- Return type:
Optional
[IConstruct
]- Returns:
the child if found, or undefined
- try_get_context(key)
Retrieves a value from tree context.
Context is usually initialized at the root, but can be overridden at any point in the tree.
- Parameters:
key (
str
) – The context key.- Return type:
Any
- Returns:
The context value or
undefined
if there is no context value for the key.
- try_remove_child(child_name)
Remove the child with the given name, if present.
- Parameters:
child_name (
str
) –- Return type:
bool
- Returns:
Whether a child with the given name was deleted.
Attributes
- PATH_SEP = '/'
- addr
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 value:
c83a2846e506bcc5f10682b564084bca2d275709ee
- children
All direct children of this construct.
- default_child
Returns the child construct that has the id
Default
orResource"
.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.
- Returns:
a construct or undefined if there is no default child
- Throws:
if there is more than one child
- dependencies
Return all dependencies registered on this node or any of its children.
- id
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
uniqueId
.
- locked
Returns true if this construct or the scopes in which it is defined are locked.
- metadata
(deprecated) DEPRECATED.
- Deprecated:
use
metadataEntry
- Stability:
deprecated
- metadata_entry
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.
- path
The full, absolute path of this construct in the tree.
Components are separated by ‘/’.
- root
The root of the construct tree.
- Type:
return
- scope
Returns the scope in which this construct is defined.
The value is
undefined
at the root of the construct scope tree.
- scopes
All parent scopes of this construct.
- Returns:
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.
- unique_id
(deprecated) A tree-global unique alphanumeric identifier for this construct.
Includes all components of the tree.
- Deprecated:
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, useNames.uniqueId()
.- Stability:
deprecated
Static Methods
- classmethod prepare(node)
(deprecated) Invokes “prepare” on all constructs (depth-first, post-order) in the tree under
node
.- Parameters:
node (
ConstructNode
) – The root node.- Deprecated:
Use
app.synth()
instead- Stability:
deprecated
- Return type:
None
- classmethod synth(node, *, outdir=None, skip_validation=None, validate_on_synthesis=None, runtime_info=None)
(deprecated) Synthesizes a CloudAssembly from a construct tree.
- Parameters:
node (
ConstructNode
) – The root of the construct tree.outdir (
Optional
[str
]) – (deprecated) The output directory into which to synthesize the cloud assembly. Default: - creates a temporary directoryskip_validation (
Optional
[bool
]) – (deprecated) Whether synthesis should skip the validation phase. Default: falsevalidate_on_synthesis (
Optional
[bool
]) – (deprecated) Whether the stack should be validated after synthesis to check for error metadata. Default: - falseruntime_info (
Union
[RuntimeInfo
,Dict
[str
,Any
],None
]) – (deprecated) Include the specified runtime information (module versions) in manifest. Default: - if this option is not specified, runtime info will not be included
- Deprecated:
Use
app.synth()
orstage.synth()
instead- Stability:
deprecated
- Return type:
- classmethod validate(node)
Invokes “validate” on all constructs in the tree (depth-first, pre-order) and returns the list of all errors.
An empty list indicates that there are no errors.
- Parameters:
node (
ConstructNode
) – The root node.- Return type:
List
[ValidationError
]