3

Here's the sample CloudFormation syntax I am seeing in the AWS documentations for AWS::Lambda::EventSourceMapping:

Type: "AWS::Lambda::EventSourceMapping"
Properties: 
  BatchSize: Integer
  Enabled: Boolean
  EventSourceArn: String
  FunctionName: String
  StartingPosition: String

Say I have a set of DDB Stream ARNs which I want to use as trigger of one lambda function (instead of one ARN as trigger). I tried to define this relationship like this:

Parameters:
   DDBStreamARN:
     Type: String
     Default: arn:aws:dynamodb:us-west-2:someId1
     AllowedValues:
       - arn:aws:dynamodb:us-west-2:someId1
       - arn:aws:dynamodb:us-west-2:someId2
       - ...
     Description: ARNs for the DDB Streams

Resources:
  RegistrationRequestStreamMapping:
     Type: AWS::Lambda::EventSourceMapping
     Properties:
       BatchSize: 70
       EventSourceArn:
         Ref: DDBStreamARN
       FunctionName:
         Fn::GetAtt:
           - TestLambdaFunction
           - Arn
       StartingPosition: TRIM_HORIZON
       Enabled: True

But the syntax doesn't seem to work since only the default value (arn:aws:dynamodb:us-west-2:someId1) is working as trigger and the other ARNs wont trigger the lambda function. Any suggestion on how to fix this?

Yar
  • 7,020
  • 11
  • 49
  • 69

2 Answers2

2

You can define many AWS::Lambda::EventSourceMapping for same lambda.

For example;

RegistrationRequestStreamMapping1:
     Type: AWS::Lambda::EventSourceMapping
     Properties:
       BatchSize: 70
       EventSourceArn:
         Ref: DDBStream1ARN
       FunctionName:
         Fn::GetAtt:
           - TestLambdaFunction
           - Arn
       StartingPosition: TRIM_HORIZON
       Enabled: True

RegistrationRequestStreamMapping2:
     Type: AWS::Lambda::EventSourceMapping
     Properties:
       BatchSize: 70
       EventSourceArn:
         Ref: DDBStream2ARN
       FunctionName:
         Fn::GetAtt:
           - TestLambdaFunction
           - Arn
       StartingPosition: TRIM_HORIZON
       Enabled: True
omerkarabacak
  • 124
  • 1
  • 9
1

Deploy your CFT twice. Once with arn:aws:dynamodb:us-west-2:someId1 and second time with arn:aws:dynamodb:us-west-2:someId2 as the value of DDBStreamARN parameter.

Asdfg
  • 11,362
  • 24
  • 98
  • 175