{
  "typeName" : "AWS::ApplicationInsights::Application",
  "description" : "Resource Type definition 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_-]*([:/].+)*$"
    },
    "SNSNotificationArn" : {
      "description" : "Application Insights sends notifications to this SNS topic whenever there is a problem update in the associated application.",
      "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" ]
    },
    "AttachMissingPermission" : {
      "description" : "If set to true, the managed policies for SSM and CW will be attached to the instance roles if they are missing",
      "type" : "boolean"
    }
  },
  "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
        },
        "Processes" : {
          "description" : "A list of processes to monitor for the component. Only Windows EC2 instances can have a processes section.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Process"
          },
          "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"
        },
        "NetWeaverPrometheusExporter" : {
          "description" : "The NetWeaver Prometheus Exporter settings.",
          "$ref" : "#/definitions/NetWeaverPrometheusExporter"
        },
        "SQLServerPrometheusExporter" : {
          "description" : "The SQL Prometheus Exporter settings.",
          "$ref" : "#/definitions/SQLServerPrometheusExporter"
        }
      },
      "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
        },
        "Processes" : {
          "description" : "A list of processes to monitor for the component. Only Windows EC2 instances can have a processes section.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Process"
          },
          "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
    },
    "NetWeaverPrometheusExporter" : {
      "description" : "The NetWeaver Prometheus Exporter Settings.",
      "type" : "object",
      "properties" : {
        "SAPSID" : {
          "description" : "SAP NetWeaver SID.",
          "type" : "string"
        },
        "InstanceNumbers" : {
          "description" : "SAP instance numbers for ASCS, ERS, and App Servers.",
          "type" : "array",
          "items" : {
            "type" : "string",
            "minLength" : 1,
            "maxLength" : 2,
            "pattern" : "\\b([0-9]|[0-9][0-9])\\b"
          }
        },
        "PrometheusPort" : {
          "description" : "Prometheus exporter port.",
          "type" : "string"
        }
      },
      "required" : [ "SAPSID", "InstanceNumbers" ],
      "additionalProperties" : false
    },
    "SQLServerPrometheusExporter" : {
      "description" : "The SQL prometheus exporter settings.",
      "type" : "object",
      "properties" : {
        "PrometheusPort" : {
          "description" : "Prometheus exporter port.",
          "type" : "string"
        },
        "SQLSecretName" : {
          "description" : "Secret name which managers SQL exporter connection. e.g. {\"data_source_name\": \"sqlserver://<USERNAME>:<PASSWORD>@localhost:1433\"}",
          "type" : "string"
        }
      },
      "required" : [ "PrometheusPort", "SQLSecretName" ],
      "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
    },
    "Process" : {
      "description" : "A process to be monitored for the component.",
      "type" : "object",
      "properties" : {
        "ProcessName" : {
          "description" : "The name of the process to be monitored for the component.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256,
          "pattern" : "^[a-zA-Z0-9_,-]+$"
        },
        "AlarmMetrics" : {
          "description" : "A list of metrics to monitor for the component.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AlarmMetric"
          },
          "insertionOrder" : true
        }
      },
      "required" : [ "ProcessName", "AlarmMetrics" ],
      "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" ],
  "writeOnlyProperties" : [ "/properties/ComponentMonitoringSettings", "/properties/LogPatternSets", "/properties/CustomComponents", "/properties/GroupingType", "/properties/OpsItemSNSTopicArn", "/properties/SNSNotificationArn", "/properties/AttachMissingPermission" ],
  "createOnlyProperties" : [ "/properties/ResourceGroupName", "/properties/GroupingType" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "applicationinsights:CreateApplication", "applicationinsights:DescribeApplication", "applicationinsights:CreateComponent", "applicationinsights:DescribeComponent", "applicationinsights:CreateLogPattern", "applicationinsights:DescribeLogPattern", "applicationinsights:DescribeComponentConfigurationRecommendation", "applicationinsights:UpdateComponentConfiguration", "applicationinsights:ListComponents", "applicationinsights:TagResource", "ec2:DescribeInstances", "ec2:DescribeVolumes", "rds:DescribeDBInstances", "rds:DescribeDBClusters", "sqs:ListQueues", "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeTargetHealth", "autoscaling:DescribeAutoScalingGroups", "lambda:ListFunctions", "dynamodb:ListTables", "s3:ListAllMyBuckets", "sns:ListTopics", "states:ListStateMachines", "apigateway:GET", "ecs:ListClusters", "ecs:DescribeTaskDefinition", "ecs:ListServices", "ecs:ListTasks", "eks:ListClusters", "eks:ListNodegroups", "fsx:DescribeFileSystems", "logs:DescribeLogGroups", "elasticfilesystem:DescribeFileSystems" ],
      "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" ]
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "applicationinsights:ListTagsForResource", "applicationinsights:TagResource", "applicationinsights:UntagResource" ]
  }
}