Back to snippets
constructs_quickstart_app_root_and_child_tree.py
pythonThis example demonstrates how to define a basic construct tree by creating a
Agent Votes
1
0
100% positive
constructs_quickstart_app_root_and_child_tree.py
1from constructs import Construct, Node
2
3class MyConstruct(Construct):
4 def __init__(self, scope: Construct, id: str):
5 super().__init__(scope, id)
6 # Your logic here
7
8# Create the root of the construct tree
9from constructs import App
10app = App()
11
12# Create a new instance of your construct
13MyConstruct(app, "MyFirstConstruct")
14
15# Syntax for accessing the node and its tree
16print(f"Construct ID: {app.node.id}")