{
  "typeName" : "AWS::CE::AnomalySubscription",
  "description" : "AWS Cost Anomaly Detection leverages advanced Machine Learning technologies to identify anomalous spend and root causes, so you can quickly take action. Create subscription to be notified",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "Arn" : {
      "description" : "Subscription ARN",
      "type" : "string",
      "pattern" : "^arn:aws[-a-z0-9]*:[a-z0-9]+:[-a-z0-9]*:[0-9]{12}:[-a-zA-Z0-9/:_]+$"
    },
    "Subscriber" : {
      "type" : "object",
      "properties" : {
        "Address" : {
          "type" : "string",
          "pattern" : "(^[a-zA-Z0-9.!#$%&'*+=?^_‘{|}~-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$)|(^arn:(aws[a-zA-Z-]*):sns:[a-zA-Z0-9-]+:[0-9]{12}:[a-zA-Z0-9_-]+(\\.fifo)?$)"
        },
        "Status" : {
          "type" : "string",
          "enum" : [ "CONFIRMED", "DECLINED" ]
        },
        "Type" : {
          "type" : "string",
          "enum" : [ "EMAIL", "SNS" ]
        }
      },
      "required" : [ "Address", "Type" ],
      "additionalProperties" : false
    },
    "ResourceTag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Key" : {
          "type" : "string",
          "description" : "The key name for the tag.",
          "pattern" : "^(?!aws:).*$",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "description" : "The value for the tag.",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ]
    }
  },
  "properties" : {
    "SubscriptionArn" : {
      "$ref" : "#/definitions/Arn"
    },
    "SubscriptionName" : {
      "description" : "The name of the subscription.",
      "type" : "string",
      "pattern" : "[\\S\\s]*",
      "minLength" : 0,
      "maxLength" : 1024
    },
    "AccountId" : {
      "description" : "The accountId",
      "type" : "string",
      "minLength" : 0,
      "maxLength" : 1024
    },
    "MonitorArnList" : {
      "description" : "A list of cost anomaly monitors.",
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Arn"
      }
    },
    "Subscribers" : {
      "description" : "A list of subscriber",
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Subscriber"
      }
    },
    "Threshold" : {
      "description" : "The dollar value that triggers a notification if the threshold is exceeded. ",
      "type" : "number",
      "minimum" : 0
    },
    "ThresholdExpression" : {
      "description" : "An Expression object in JSON String format used to specify the anomalies that you want to generate alerts for.",
      "type" : "string"
    },
    "Frequency" : {
      "description" : "The frequency at which anomaly reports are sent over email. ",
      "type" : "string",
      "enum" : [ "DAILY", "IMMEDIATE", "WEEKLY" ]
    },
    "ResourceTags" : {
      "type" : "array",
      "description" : "Tags to assign to subscription.",
      "items" : {
        "$ref" : "#/definitions/ResourceTag"
      },
      "minItems" : 0,
      "maxItems" : 200,
      "insertionOrder" : false
    }
  },
  "additionalProperties" : false,
  "required" : [ "MonitorArnList", "Subscribers", "Frequency", "SubscriptionName" ],
  "createOnlyProperties" : [ "/properties/ResourceTags" ],
  "readOnlyProperties" : [ "/properties/SubscriptionArn", "/properties/AccountId", "/properties/Subscribers/*/Status" ],
  "primaryIdentifier" : [ "/properties/SubscriptionArn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "ce:CreateAnomalySubscription", "ce:TagResource" ]
    },
    "read" : {
      "permissions" : [ "ce:GetAnomalySubscriptions", "ce:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "ce:UpdateAnomalySubscription" ]
    },
    "delete" : {
      "permissions" : [ "ce:DeleteAnomalySubscription" ]
    },
    "list" : {
      "permissions" : [ "ce:GetAnomalySubscriptions" ]
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : false,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/ResourceTags",
    "permissions" : [ "ce:ListTagsForResource" ]
  }
}