ConstructNode¶
-
class
aws_cdk.core.
ConstructNode
(host, scope, id)¶ Bases:
object
Represents the construct node in the scope tree.
- 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
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
- Return type
None
-
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)¶ (experimental) 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.
- Stability
experimental
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:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 c83a2846e506bcc5f10682b564084bca2d275709ee
- Return type
str
-
children
¶ All direct children of this construct.
- Return type
List
[IConstruct
]
-
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.
- Return type
Optional
[IConstruct
]- 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.
- Return type
List
[Dependency
]
-
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
.- Return type
str
-
locked
¶ Returns true if this construct or the scopes in which it is defined are locked.
- Return type
bool
-
metadata
¶ 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.
- Return type
List
[MetadataEntry
]
-
path
¶ The full, absolute path of this construct in the tree.
Components are separated by ‘/’.
- Return type
str
-
root
¶ The root of the construct tree.
- Type
return
- Return type
-
scope
¶ Returns the scope in which this construct is defined.
The value is
undefined
at the root of the construct scope tree.- Return type
Optional
[IConstruct
]
-
scopes
¶ All parent scopes of this construct.
- Return type
List
[IConstruct
]- 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)- Stability
deprecated
- Return type
str
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, 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: falseruntime_info (
Optional
[RuntimeInfo
]) – (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
]