deployment/ElbHostnameAsTargetUsingLambdaExistingInfra.yaml [331:403]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  SnsTopic:
    Condition: CreateAlarms
    Type: AWS::SNS::Topic
    Properties:
      Subscription:
        - Endpoint: !Ref CompositeAlarmSnsEmail
          Protocol: email
      TopicName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-sns-topic'

  LambdaInvocationsAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Lambda invocations. Alarms when function invocation reports an error
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-invocations'
      MetricName: Invocations
      Namespace: AWS/Lambda
      Dimensions:
        - Name: FunctionName
          Value: !Ref ElbHostnameTarget
      Period: 60
      EvaluationPeriods: 1
      DatapointsToAlarm: 1
      Threshold: 1  
      ComparisonOperator: LessThanThreshold
      Statistic: Sum
      TreatMissingData: breaching

  LambdaErrorsAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Lambda errors. Alarm when function reports an error
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-errors'
      MetricName: Errors
      Namespace: AWS/Lambda
      Dimensions:
        - Name: FunctionName
          Value: !Ref ElbHostnameTarget
      Period: 60
      EvaluationPeriods: 1
      DatapointsToAlarm: 1
      Threshold: 0
      ComparisonOperator: GreaterThanThreshold
      Statistic: Sum
      TreatMissingData: breaching

  LambdaCompositeAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::CompositeAlarm
    DependsOn:
      - LambdaInvocationsAlarm
      - LambdaErrorsAlarm    
    Properties:
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-monitor'
      AlarmRule: !Sub "(ALARM(${LambdaErrorsAlarm}) OR ALARM(${LambdaInvocationsAlarm}))"
      AlarmActions: 
        - !Ref SnsTopic
      AlarmDescription: Lambda composite. Alarm triggers when either of the metric alarms trigger

Outputs:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



deployment/ElbHostnameAsTargetUsingLambdaNewInfra.yaml [963:1035]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  SnsTopic:
    Condition: CreateAlarms
    Type: AWS::SNS::Topic
    Properties:
      Subscription:
        - Endpoint: !Ref CompositeAlarmSnsEmail
          Protocol: email
      TopicName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-sns-topic'

  LambdaInvocationsAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Lambda invocations. Alarms when function invocation reports an error
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-invocations'
      MetricName: Invocations
      Namespace: AWS/Lambda
      Dimensions:
        - Name: FunctionName
          Value: !Ref ElbHostnameTarget
      Period: 60
      EvaluationPeriods: 1
      DatapointsToAlarm: 1
      Threshold: 1  
      ComparisonOperator: LessThanThreshold
      Statistic: Sum
      TreatMissingData: breaching

  LambdaErrorsAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Lambda errors. Alarm when function reports an error
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-errors'
      MetricName: Errors
      Namespace: AWS/Lambda
      Dimensions:
        - Name: FunctionName
          Value: !Ref ElbHostnameTarget
      Period: 60
      EvaluationPeriods: 1
      DatapointsToAlarm: 1
      Threshold: 0
      ComparisonOperator: GreaterThanThreshold
      Statistic: Sum
      TreatMissingData: breaching

  LambdaCompositeAlarm:
    Condition: CreateAlarms
    Type: AWS::CloudWatch::CompositeAlarm
    DependsOn:
      - LambdaInvocationsAlarm
      - LambdaErrorsAlarm    
    Properties:
      AlarmName: !Join
        - ''
        - - !Ref ElbHostnameTarget
          - '-monitor'
      AlarmRule: !Sub "(ALARM(${LambdaErrorsAlarm}) OR ALARM(${LambdaInvocationsAlarm}))"
      AlarmActions: 
        - !Ref SnsTopic
      AlarmDescription: Lambda composite. Alarm triggers when either of the metric alarms trigger

Outputs:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



