{
  "typeName" : "AWS::ApplicationInsights::Application",
  "description" : "Resource schema for AWS::ApplicationInsights::Application",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-applicationinsights.git",
  "properties" : {
    "ResourceGroupName" : {
      "description" : "The name of the resource group.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 256,
      "pattern" : "[a-zA-Z0-9.-_]*"
    },
    "ApplicationARN" : {
      "description" : "The ARN of the ApplicationInsights application.",
      "type" : "string"
    },
    "CWEMonitorEnabled" : {
      "description" : "Indicates whether Application Insights can listen to CloudWatch events for the application resources.",
      "type" : "boolean"
    },
    "OpsCenterEnabled" : {
      "description" : "When set to true, creates opsItems for any problems detected on an application.",
      "type" : "boolean"
    },
    "OpsItemSNSTopicArn" : {
      "description" : "The SNS topic provided to Application Insights that is associated to the created opsItem.",
      "type" : "string",
      "minLength" : 20,
      "maxLength" : 300,
      "pattern" : "^arn:aws(-[\\w]+)*:[\\w\\d-]+:([\\w\\d-]*)?:[\\w\\d_-]*([:/].+)*$"
    },
    "Tags" : {
      "description" : "The tags of Application Insights application.",
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Tag"
      },
      "minItems" : 1,
      "insertionOrder" : true
    },
    "CustomComponents" : {
      "description" : "The custom grouped components.",
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/CustomComponent"
      },
      "minItems" : 1,
      "insertionOrder" : true
    },
    "LogPatternSets" : {
      "description" : "The log pattern sets.",
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/LogPatternSet"
      },
      "minItems" : 1,
      "insertionOrder" : true
    },
    "AutoConfigurationEnabled" : {
      "description" : "If set to true, application will be configured with recommended monitoring configuration.",
      "type" : "boolean"
    },
    "ComponentMonitoringSettings" : {
      "description" : "The monitoring settings of the components.",
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/ComponentMonitoringSetting"
      },
      "minItems" : 1,
      "insertionOrder" : true
    },
    "GroupingType" : {
      "description" : "The grouping type of the application",
      "type" : "string",
      "enum" : [ "ACCOUNT_BASED" ]
    }
  },
  "definitions" : {
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "properties" : {
        "Key" : {
          "description" : "The key name of the tag. You can specify a value that is 1 to 127 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -. ",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "description" : "The value for the tag. You can specify a value that is 1 to 255 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -. ",
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "CustomComponent" : {
      "description" : "The custom grouped component.",
      "type" : "object",
      "properties" : {
        "ComponentName" : {
          "description" : "The name of the component.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128,
          "pattern" : "^[\\d\\w\\-_.+]*$"
        },
        "ResourceList" : {
          "description" : "The list of resource ARNs that belong to the component.",
          "type" : "array",
          "items" : {
            "type" : "string",
            "minLength" : 20,
            "maxLength" : 300,
            "pattern" : "^arn:aws(-[\\w]+)*:[\\w\\d-]+:([\\w\\d-]*)?:[\\w\\d_-]*([:/].+)*$"
          },
          "minItems" : 1,
          "insertionOrder" : true
        }
      },
      "required" : [ "ComponentName", "ResourceList" ],
      "additionalProperties" : false
    },
    "LogPatternSet" : {
      "description" : "The log pattern set.",
      "type" : "object",
      "properties" : {
        "PatternSetName" : {
          "description" : "The name of the log pattern set.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 30,
          "pattern" : "[a-zA-Z0-9.-_]*"
        },
        "LogPatterns" : {
          "description" : "The log patterns of a set.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/LogPattern"
          },
          "minItems" : 1,
          "insertionOrder" : true
        }
      },
      "required" : [ "PatternSetName", "LogPatterns" ],
      "additionalProperties" : false
    },
    "LogPattern" : {
      "description" : "The log pattern.",
      "type" : "object",
      "properties" : {
        "PatternName" : {
          "description" : "The name of the log pattern.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 50,
          "pattern" : "[a-zA-Z0-9.-_]*"
        },
        "Pattern" : {
          "description" : "The log pattern.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 50
        },
        "Rank" : {
          "description" : "Rank of the log pattern.",
          "type" : "integer"
        }
      },
      "required" : [ "PatternName", "Pattern", "Rank" ],
      "additionalProperties" : false
    },
    "ComponentMonitoringSetting" : {
      "description" : "The monitoring setting of the component.",
      "type" : "object",
      "properties" : {
        "ComponentName" : {
          "description" : "The name of the component.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128,
          "pattern" : "^[\\d\\w\\-_.+]*$"
        },
        "ComponentARN" : {
          "description" : "The ARN of the compnonent.",
          "type" : "string",
          "minLength" : 20,
          "maxLength" : 300,
          "pattern" : "^arn:aws(-[\\w]+)*:[\\w\\d-]+:([\\w\\d-]*)?:[\\w\\d_-]*([:/].+)*$"
        },
        "Tier" : {
          "description" : "The tier of the application component.",
          "type" : "string",
          "pattern" : "^[A-Z][[A-Z]_]*$"
        },
        "ComponentConfigurationMode" : {
          "description" : "The component monitoring configuration mode.",
          "type" : "string",
          "enum" : [ "DEFAULT", "DEFAULT_WITH_OVERWRITE", "CUSTOM" ]
        },
        "DefaultOverwriteComponentConfiguration" : {
          "description" : "The overwritten settings on default component monitoring configuration.",
          "$ref" : "#/definitions/ComponentConfiguration"
        },
        "CustomComponentConfiguration" : {
          "description" : "The monitoring configuration of the component.",
          "$ref" : "#/definitions/ComponentConfiguration"
        }
      },
      "required" : [ "Tier", "ComponentConfigurationMode" ],
      "oneOf" : [ {
        "required" : [ "ComponentName" ]
      }, {
        "required" : [ "ComponentARN" ]
      } ],
      "additionalProperties" : false
    },
    "ComponentConfiguration" : {
      "description" : "The configuration settings of the component.",
      "type" : "object",
      "properties" : {
        "ConfigurationDetails" : {
          "description" : "The configuration settings",
          "$ref" : "#/definitions/ConfigurationDetails"
        },
        "SubComponentTypeConfigurations" : {
          "description" : "Sub component configurations of the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/SubComponentTypeConfiguration"
          },
          "minItems" : 1,
          "insertionOrder" : true
        }
      },
      "additionalProperties" : false
    },
    "ConfigurationDetails" : {
      "description" : "The configuration settings.",
      "type" : "object",
      "properties" : {
        "AlarmMetrics" : {
          "description" : "A list of metrics to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AlarmMetric"
          },
          "insertionOrder" : true
        },
        "Logs" : {
          "description" : "A list of logs to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Log"
          },
          "insertionOrder" : true
        },
        "WindowsEvents" : {
          "description" : "A list of Windows Events to log.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/WindowsEvent"
          },
          "insertionOrder" : true
        },
        "Alarms" : {
          "description" : "A list of alarms to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Alarm"
          },
          "insertionOrder" : true
        },
        "JMXPrometheusExporter" : {
          "description" : "The JMX Prometheus Exporter settings.",
          "$ref" : "#/definitions/JMXPrometheusExporter"
        },
        "HANAPrometheusExporter" : {
          "description" : "The HANA DB Prometheus Exporter settings.",
          "$ref" : "#/definitions/HANAPrometheusExporter"
        },
        "HAClusterPrometheusExporter" : {
          "description" : "The HA cluster Prometheus Exporter settings.",
          "$ref" : "#/definitions/HAClusterPrometheusExporter"
        }
      },
      "additionalProperties" : false
    },
    "SubComponentConfigurationDetails" : {
      "description" : "The configuration settings of sub components.",
      "type" : "object",
      "properties" : {
        "AlarmMetrics" : {
          "description" : "A list of metrics to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AlarmMetric"
          },
          "insertionOrder" : true
        },
        "Logs" : {
          "description" : "A list of logs to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Log"
          },
          "insertionOrder" : true
        },
        "WindowsEvents" : {
          "description" : "A list of Windows Events to log.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/WindowsEvent"
          },
          "insertionOrder" : true
        }
      },
      "additionalProperties" : false
    },
    "JMXPrometheusExporter" : {
      "description" : "The JMX Prometheus Exporter settings.",
      "type" : "object",
      "properties" : {
        "JMXURL" : {
          "description" : "JMX service URL.",
          "type" : "string"
        },
        "HostPort" : {
          "description" : "Java agent host port",
          "type" : "string"
        },
        "PrometheusPort" : {
          "description" : "Prometheus exporter port.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "HANAPrometheusExporter" : {
      "description" : "The HANA DB Prometheus Exporter settings.",
      "type" : "object",
      "properties" : {
        "HANASID" : {
          "description" : "HANA DB SID.",
          "type" : "string"
        },
        "HANAPort" : {
          "description" : "The HANA DB port.",
          "type" : "string"
        },
        "HANASecretName" : {
          "description" : "The secret name which manages the HANA DB credentials e.g. {\n  \"username\": \"<>\",\n  \"password\": \"<>\"\n}.",
          "type" : "string"
        },
        "AgreeToInstallHANADBClient" : {
          "description" : "A flag which indicates agreeing to install SAP HANA DB client.",
          "type" : "boolean"
        },
        "PrometheusPort" : {
          "description" : "Prometheus exporter port.",
          "type" : "string"
        }
      },
      "required" : [ "HANASID", "HANAPort", "HANASecretName", "AgreeToInstallHANADBClient" ],
      "additionalProperties" : false
    },
    "HAClusterPrometheusExporter" : {
      "description" : "The HA cluster Prometheus Exporter settings.",
      "type" : "object",
      "properties" : {
        "PrometheusPort" : {
          "description" : "Prometheus exporter port.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "AlarmMetric" : {
      "description" : "A metric to be monitored for the component.",
      "type" : "object",
      "properties" : {
        "AlarmMetricName" : {
          "description" : "The name of the metric to be monitored for the component.",
          "type" : "string"
        }
      },
      "required" : [ "AlarmMetricName" ],
      "additionalProperties" : false
    },
    "Log" : {
      "description" : "A log to be monitored for the component.",
      "type" : "object",
      "properties" : {
        "LogGroupName" : {
          "description" : "The CloudWatch log group name to be associated to the monitored log.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 512,
          "pattern" : "[\\.\\-_/#A-Za-z0-9]+"
        },
        "LogPath" : {
          "description" : "The path of the logs to be monitored.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 260,
          "pattern" : "^([a-zA-Z]:\\\\[\\\\\\S|*\\S]?.*|/[^\"']*)$"
        },
        "LogType" : {
          "description" : "The log type decides the log patterns against which Application Insights analyzes the log.",
          "type" : "string",
          "pattern" : "^[A-Z][[A-Z]_]*$"
        },
        "Encoding" : {
          "description" : "The type of encoding of the logs to be monitored.",
          "type" : "string",
          "enum" : [ "utf-8", "utf-16", "ascii" ]
        },
        "PatternSet" : {
          "description" : "The name of the log pattern set.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 30,
          "pattern" : "[a-zA-Z0-9.-_]*"
        }
      },
      "required" : [ "LogType" ],
      "additionalProperties" : false
    },
    "WindowsEvent" : {
      "description" : "A Windows Event to be monitored for the component.",
      "type" : "object",
      "properties" : {
        "LogGroupName" : {
          "description" : "The CloudWatch log group name to be associated to the monitored log.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 512,
          "pattern" : "[\\.\\-_/#A-Za-z0-9]+"
        },
        "EventName" : {
          "description" : "The type of Windows Events to log.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 260,
          "pattern" : "^[a-zA-Z0-9_ \\\\/-]$"
        },
        "EventLevels" : {
          "description" : "The levels of event to log. ",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/EventLevel"
          },
          "minItems" : 1,
          "insertionOrder" : true
        },
        "PatternSet" : {
          "description" : "The name of the log pattern set.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 30,
          "pattern" : "[a-zA-Z0-9.-_]*"
        }
      },
      "required" : [ "LogGroupName", "EventName", "EventLevels" ],
      "additionalProperties" : false
    },
    "EventLevel" : {
      "description" : "The level of event to log.",
      "type" : "string",
      "enum" : [ "INFORMATION", "WARNING", "ERROR", "CRITICAL", "VERBOSE" ]
    },
    "Alarm" : {
      "description" : "A CloudWatch alarm to be monitored for the component.",
      "type" : "object",
      "properties" : {
        "AlarmName" : {
          "description" : "The name of the CloudWatch alarm to be monitored for the component.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 255
        },
        "Severity" : {
          "description" : "Indicates the degree of outage when the alarm goes off.",
          "type" : "string",
          "enum" : [ "HIGH", "MEDIUM", "LOW" ]
        }
      },
      "required" : [ "AlarmName" ],
      "additionalProperties" : false
    },
    "SubComponentTypeConfiguration" : {
      "description" : "One type sub component configurations for the component.",
      "type" : "object",
      "properties" : {
        "SubComponentType" : {
          "description" : "The sub component type.",
          "type" : "string",
          "enum" : [ "AWS::EC2::Instance", "AWS::EC2::Volume" ]
        },
        "SubComponentConfigurationDetails" : {
          "description" : "The configuration settings of sub components.",
          "$ref" : "#/definitions/SubComponentConfigurationDetails"
        }
      },
      "required" : [ "SubComponentType", "SubComponentConfigurationDetails" ],
      "additionalProperties" : false
    }
  },
  "additionalProperties" : false,
  "required" : [ "ResourceGroupName" ],
  "primaryIdentifier" : [ "/properties/ApplicationARN" ],
  "readOnlyProperties" : [ "/properties/ApplicationARN" ],
  "createOnlyProperties" : [ "/properties/ResourceGroupName" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "applicationinsights:CreateApplication", "applicationinsights:DescribeApplication", "applicationinsights:CreateComponent", "applicationinsights:DescribeComponent", "applicationinsights:CreateLogPattern", "applicationinsights:DescribeLogPattern", "applicationinsights:DescribeComponentConfigurationRecommendation", "applicationinsights:UpdateComponentConfiguration", "applicationinsights:ListComponents" ],
      "timeoutInMinutes" : 600
    },
    "read" : {
      "permissions" : [ "applicationinsights:DescribeApplication", "applicationinsights:ListTagsForResource", "applicationinsights:DescribeComponent", "applicationinsights:ListComponents", "applicationinsights:DescribeLogPattern", "applicationinsights:ListLogPatterns", "applicationinsights:ListLogPatternSets" ]
    },
    "update" : {
      "permissions" : [ "applicationinsights:CreateApplication", "applicationinsights:DescribeApplication", "applicationinsights:UpdateApplication", "applicationinsights:TagResource", "applicationinsights:UntagResource", "applicationinsights:ListTagsForResource", "applicationinsights:CreateComponent", "applicationinsights:DescribeComponent", "applicationinsights:DeleteComponent", "applicationinsights:ListComponents", "applicationinsights:CreateLogPattern", "applicationinsights:DeleteLogPattern", "applicationinsights:DescribeLogPattern", "applicationinsights:ListLogPatterns", "applicationinsights:ListLogPatternSets", "applicationinsights:UpdateLogPattern", "applicationinsights:DescribeComponentConfiguration", "applicationinsights:DescribeComponentConfigurationRecommendation", "applicationinsights:UpdateComponentConfiguration" ],
      "timeoutInMinutes" : 600
    },
    "delete" : {
      "permissions" : [ "applicationinsights:DeleteApplication", "applicationinsights:DescribeApplication" ]
    },
    "list" : {
      "permissions" : [ "applicationinsights:ListApplications", "applicationinsights:DescribeApplication", "applicationinsights:ListTagsForResource", "applicationinsights:DescribeComponent", "applicationinsights:ListComponents", "applicationinsights:DescribeLogPattern", "applicationinsights:ListLogPatterns", "applicationinsights:ListLogPatternSets" ]
    }
  },
  "taggable" : true
}