AWSTemplateFormatVersion:  2010-09-09

Description: 'This template creates a subscriptionfilter'

Parameters: 
  LambdaEdgeFunctionName: 
    Description: The name of the LambdaEdge to apply the subscription filter to.    
    Type: String
    MinLength: 1
  CloudWatchRoleArn: 
    Description: The CloudWatch role ARN used to apply the subscription filter.   
    Type: String
    MinLength: 1
  FirehoseDestinationArn: 
    Description: The ARN for the Firehose delivery stream where logs will be aggregated.   
    Type: String
    MinLength: 1
  FilterPattern: 
    Description: A symbolic description of how CloudWatch Logs should interpret the data in each log event, along with filtering expressions that restrict what gets delivered to the destination AWS resource. Please note - If left blank, the subscription filter will match all log events. 
    Type: String
    Default: ''
Resources:
  SubscriptionFilter:
    Type: AWS::Logs::SubscriptionFilter
    Properties: 
        DestinationArn: !Ref FirehoseDestinationArn
        FilterPattern: !Ref FilterPattern
        LogGroupName: !Sub '/aws/lambda/us-east-1.${LambdaEdgeFunctionName}'
        RoleArn: !Ref CloudWatchRoleArn

  