David Perera
David Perera

Reputation: 33

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

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: "[email protected]"
      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"

Upvotes: 2

Views: 632

Answers (1)

Marcin
Marcin

Reputation: 238081

You should use single quotes:

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

Upvotes: 1

Related Questions