1
votes

I have a scenario that need to create a multiple lambda functions using AWS CDK python language.

As I have tried to create multiple stacks for each function, It's created first function and rest of the functions showing that function already existed.

if we debug the cdk.out for created templates that two stacks Lambda function showing same Resource ID like below:

"Resources": {
"LambdaFunctionBF21E41F": {
  "Type": "AWS::Lambda::Function",
  "Properties": {
    "Code": {

How to get unique IDs for the resources to create multiple functions? Could you please suggest how to overcome this? I want to create multiple lambda functions even if the solution is from creating loop is also fine and

Early response would be much appreciated. Thanks in advance

Regards, Pavan kumar D

1
You need to pass different id in the function constructor. From your template it looks like you are setting id as LambdaFunction for your function, you can add some different value for all your functions. - nirvana124
Pankaj, Here i am using python to create lambda functions and itself creating unique ID for the function. The template which pasted above was the same. So i need to create multiple lambda functions with unique ID from CDK python. - Pavan kumar D

1 Answers

0
votes

Create multiple lambda functions using the aws_lambda module function method as many as required.Add the function stack with respect to stack class to app.py file. Now when you run cdk diff/synth you can see creating functions in template(cdk.out)/console