Reputation: 171
I have had success building functions on AWS Lambda and passing parameters to the function to test and execute as I see fit. However, I am finding it hard to locate where to configure what needs to be passed to my functions on a timed event using Cloudwatch. I see the easiest way was to have no event or context (event=None and context=None) but as I have become more sophisticated I have some testing parameters now built in that require me to simply pass the following:
{
"testing" : "True"
}
Again, I already have the function up and running but now it is built to accept this when it is needing to actually perform it's job for the management team:
{
"testing" : "False"
}
I do see configs for Event Bus being set to default but I cannot locate what CloudWatch was actually doing in the first place so I can modify it (hopefully) to pass the False statement to my function.
All my functions are in python 3.7 and if more info is needed, let me know. I have reviewed questions on here regarding similar issues, such as this but cannot locate these libraries and I believe I would need to configure something custom in the future as well. Thanks
Upvotes: 0
Views: 666
Reputation: 17535
I do something similar to what you're after - I trigger a Lambda to create a snapshot of an EBS volume. I have used the console to configure my Cloudwatch events. In Events->Rules->Actions (upper right hand corner)->Edit, I have the following:
My constant JSON looks like:
{
"volumeId": "vol-0c4079999999999",
"description":"Jenkins Snapshot",
"name": "jenkins-snapshot"
}
And I parse this information out to use in my Lambda. I have multiple events that use this same Lambda and they each just have a different constant JSON in them.
Upvotes: 1