I have a lambda function created using SAM template which has an event trigger scheduled every 5 mins.
When the lambda get created for first time the event is enabled. But, when someone disables the trigger manually, the rerunning the stack does not enable it again.
Native cloud formation has an attribute called State
in AWS::Events::Rule. But this is not supported in SAM Function's Events property. It is to be noted that this Events property gets translated to AWS::Events::Rule by SAM engine.
I tried adding the same State attribute in SAM but that doen't work.
Now the question is really how do I make sure Event is always enabled when SAM is used.
This there a hack available.
Sample code:
MyUpdater:
Type: 'AWS::Serverless::Function'
Properties:
Handler: myupdater.lambda_handler
Runtime: python3.6
FunctionName: "myupdater"
CodeUri: ./code
Description: Sample updater lambda
MemorySize: 128
Timeout: 60
Role: !ImportValue myIamRole
KmsKeyArn: !ImportValue myKeyArn
Events:
Timer:
Type: Schedule
Properties:
Schedule: rate(5 minutes)
Thanks in advance
This is not possible today. We are considering this feature (CFN properties pass-through) for the future.