【问题标题】:Template format error: YAML not well-formed in metric filters模板格式错误:YAML 在指标过滤器中格式不正确
【发布时间】:2021-10-05 17:55:12
【问题描述】:

模板格式错误:YAML 格式不正确。 (第 30 行,第 36 列)。请帮我。 FilterPattern 行中出现错误

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"

【问题讨论】:

    标签: amazon-web-services yaml amazon-cloudformation


    【解决方案1】:

    你应该使用单引号:

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

    【讨论】:

    • 或者更准确地说,你不能在双引号中嵌套双引号。 "..."..."..."..."..." 对解析器不可读,但 '..."..."..."..."...' 是。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 2014-05-18
    • 1970-01-01
    • 2022-11-18
    相关资源
    最近更新 更多