Myeongjang JO
Myeongjang JO

Reputation: 91

Can I use CloudWatch Event to trigger Lambda function that has variety event value?

I have a question to use CloudWatch Event.

We will support a mailing service daily for various customers using AWS Lambda and CloudWatch Event.

Fortunately, we don't need a variety of function codes, just need one function code to execute the mailing program.

But we need a variety of Lambda test event values. For example customer's email address, kind of resources.

I think we don't need to duplicate the Lambda function for each customer if we can alternately input values into the test event.

But I don't know how to make a CloudWatch Event that triggers the Lambda input test event value to run by changing it.

Can I make it?

Upvotes: 0

Views: 716

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269284

You do not mention what type of trigger is being used, so I will assume that it is a scheduled event.

When configuring the Target for the event as an AWS Lambda function, you can "Configure input". This will control what information is sent to the function in the event record.

For your use-case, you could use Constant (JSON text) to pass a static set of parameters to the function. This information would come through in the event record, which your Lambda function can parse and then act appropriately.

Event target input configuration

Please note that these are not 'test events' -- they are the real events that are sent through to the function. 'Test' events are only used in the AWS Lambda management console when you use the Test button, to simulate a normal triggering of the function.

Upvotes: 1

Related Questions