AWS CloudWatch Alarm triggers immediately during CloudFormation stack creation - how to delay monitoring?

Viewed 103

I have some CloudWatch alarms that I am creating with my lambda function in a CloudFormation template. The alarms monitor the errors, invocations and duration metrics of the lambda function. An example of one of the alarms is below.

The alarms trigger as soon as they are created, which is actually before the stack creation has completed. How do I delay the monitoring of the alarms so that they don't start monitoring until the lambda function has executed at least once?

My lambda function is scheduled to run every 5 mintues, so it is over 5 minutes after creating the stack before the alarm goes green.

LambdaAlarmInvocations:
  Type: 'AWS::CloudWatch::Alarm'
  Properties:
    ActionsEnabled: true
    AlarmName: !Sub '${LambdaFunctionName}-Alarm-Invocations'
    ComparisonOperator: LessThanOrEqualToThreshold
    EvaluationPeriods: 1
    MetricName: Invocations
    Namespace: AWS/Lambda
    Statistic: Average
    Threshold: 0
    DatapointsToAlarm: 1
    Dimensions:
      - Name: FunctionName
        Value: !Sub '${LambdaFunctionName}'
    Period: 180
    TreatMissingData: breaching

I assume the breaching is the issue here, but I think I need breaching to catch for when the data metric is missing.

Or perhaps I am misunderstanding this parameter?

0 Answers
Related