AWSTemplateFormatVersion: "2010-09-09"
Description: DT CloudWatch stack
Parameters:
  #------------------------
  # Deployment Information
  #------------------------
  environment:
    Type: String
    Description: Name of the environment
    Default: production

  #----------------
  # ECS Information
  #----------------
  Cluster:
    Description: The ECS cluster to watch
    Type: String

  #-------------------
  # Lambda Information
  #-------------------
  LambdaArn:
    Description: Lambda function to call upon ecs task state change
    Type: String

Resources:

  TaskListRule:
    EventPattern:
      source:
      - "aws.ecs"
      detail-type:
      - "ECS Task State Change"
      detail:
        clusterArn:
        - !Ref Cluster
    Targets:
    - Id: RedisUpdater
      Arn: !Ref LambdaArn