0
votes

I'm trying to automate the lambda creation process.

I have put the lambda creation function inside a loop and I got this problem: when I check the lambda functions created on the AWS dashboard, reading the content (the source code) I see that all the lambdas have the same code.

lambda_function = _lambda.Function(self,
                                           id=function['lambda_name'],
                                           handler='lambda_function.lambda_handler',
                                           runtime=_lambda.Runtime.PYTHON_3_8,
                                           code=_lambda.Code.from_asset(tmp_lambda_path),
                                           memory_size=function.get('memory_size', 320),
                                           timeout=core.Duration.minutes(1),
                                           log_retention=_logs.RetentionDays.THREE_DAYS,
                                           layers=[app_layer])
1

1 Answers

0
votes

Based on what you are describing problem looks to be in

code=_lambda.Code.from_asset(tmp_lambda_path)

tmp_lambda_path might be same for all loop iterations. It's impossible to tell certainly however as only fraction of the code was posted.