Template format error: YAML not well-formed in metric filters

Viewed 296

Template format error: YAML not well-formed. (line 30, column 36). Please Help Me. Error comes in FilterPattern line

AWSTemplateFormatVersion: "2010-09-09"

Resources:
 MySNSTopic:
  Type: AWS::SNS::Topic
  Properties:
    Subscription:
    - Endpoint: "abcd@abcd.com"
      Protocol: email
   
 snstopic: 
  Type: AWS::Logs::LogGroup
  DependsOn: MySNSTopic
  Properties: 
    RetentionInDays: 7
  
 UnauthorizedApiCalls: 
  Type: AWS::Logs::MetricFilter
  DependsOn: snstopic
  Properties: 
    LogGroupName: 
      Ref: "snstopic"
    FilterPattern: "{($.errorCode="*UnauthorizedOperation") || ($.errorCode="AccessDenied*")}"
    MetricTransformations: 
      - 
        MetricValue: "1"
        MetricNamespace: "unauthorized-api-calls"
        MetricName: "LogMetrics"
1 Answers

You should use single quotes:

FilterPattern: '{($.errorCode="*UnauthorizedOperation") || ($.errorCode="AccessDenied*")}'
Related