-
Hello, I need to access the How to do it? from aws_cdk import aws_lambda
from constructs import Construct
class Foo(Construct):
def __init__(self, scope: Construct, construct_id: str) -> None:
super().__init__(scope, construct_id)
functions = [
self.setup_lambda("foo1"),
self.setup_lambda("foo2"),
self.setup_lambda("foo3"),
]
# Expected to print "foo1", "foo2" and "foo3"
for function in functions:
print(function.id) # Error: Cannot access attribute "id"
def setup_lambda(self, function_id: str) -> aws_lambda.Function:
function = aws_lambda.Function(
scope=self,
id=function_id,
runtime=aws_lambda.Runtime.PYTHON_3_12,
code=aws_lambda.Code.from_asset(f"foo/{function_id}"),
handler=f"{function_id}.handler",
)
return function |
Beta Was this translation helpful? Give feedback.
Answered by
rafrafek
May 29, 2024
Replies: 2 comments
-
The answer is simple: print(function.node.id) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rafrafek
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The answer is simple: