{
  "typeName" : "AWS::RUM::AppMonitor",
  "description" : "Resource Type definition for AWS::RUM::AppMonitor",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "AppMonitorConfiguration" : {
      "description" : "AppMonitor configuration",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "IdentityPoolId" : {
          "description" : "The ID of the identity pool that is used to authorize the sending of data to RUM.",
          "minLength" : 1,
          "maxLength" : 55,
          "pattern" : "[\\w-]+:[0-9a-f-]+",
          "type" : "string"
        },
        "ExcludedPages" : {
          "description" : "A list of URLs in your website or application to exclude from RUM data collection. You can't include both ExcludedPages and IncludedPages in the same operation.",
          "$ref" : "#/definitions/Pages"
        },
        "IncludedPages" : {
          "description" : "If this app monitor is to collect data from only certain pages in your application, this structure lists those pages. You can't include both ExcludedPages and IncludedPages in the same operation.",
          "$ref" : "#/definitions/Pages"
        },
        "FavoritePages" : {
          "description" : "A list of pages in the RUM console that are to be displayed with a favorite icon.",
          "$ref" : "#/definitions/FavoritePages"
        },
        "SessionSampleRate" : {
          "description" : "Specifies the percentage of user sessions to use for RUM data collection. Choosing a higher percentage gives you more data but also incurs more costs. The number you specify is the percentage of user sessions that will be used. If you omit this parameter, the default of 10 is used.",
          "type" : "number",
          "minimum" : 0,
          "maximum" : 1
        },
        "GuestRoleArn" : {
          "description" : "The ARN of the guest IAM role that is attached to the identity pool that is used to authorize the sending of data to RUM.",
          "$ref" : "#/definitions/Arn"
        },
        "AllowCookies" : {
          "description" : "If you set this to true, the RUM web client sets two cookies, a session cookie and a user cookie. The cookies allow the RUM web client to collect data relating to the number of users an application has and the behavior of the application across a sequence of events. Cookies are stored in the top-level domain of the current page.",
          "type" : "boolean"
        },
        "Telemetries" : {
          "description" : "An array that lists the types of telemetry data that this app monitor is to collect.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Telemetry"
          },
          "insertionOrder" : false
        },
        "EnableXRay" : {
          "description" : "If you set this to true, RUM enables xray tracing for the user sessions that RUM samples. RUM adds an xray trace header to allowed HTTP requests. It also records an xray segment for allowed HTTP requests. You can see traces and segments from these user sessions in the xray console and the CW ServiceLens console.",
          "type" : "boolean"
        },
        "MetricDestinations" : {
          "description" : "An array of structures which define the destinations and the metrics that you want to send.",
          "type" : "array",
          "minItems" : 0,
          "maxItems" : 20,
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/MetricDestination"
          }
        }
      }
    },
    "TagDef" : {
      "description" : "Assigns one or more tags (key-value pairs) to the app monitor. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. Tags don't have any semantic meaning to AWS and are interpreted strictly as strings of characters.You can associate as many as 50 tags with an app monitor.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "pattern" : "^(?!aws:)[a-zA-Z+-=._:/]+$",
          "description" : "The key name of the tag. You can specify a value that is 1 to 128 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 -. ",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "description" : "The value for the tag. You can specify a value that is 0 to 256 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 -. ",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Value", "Key" ]
    },
    "Pages" : {
      "type" : "array",
      "description" : "List of url pages",
      "minItems" : 0,
      "maxItems" : 50,
      "items" : {
        "$ref" : "#/definitions/Url"
      },
      "insertionOrder" : false
    },
    "FavoritePages" : {
      "type" : "array",
      "description" : "List of favorite pages",
      "minItems" : 0,
      "maxItems" : 50,
      "items" : {
        "type" : "string"
      },
      "insertionOrder" : false
    },
    "Url" : {
      "description" : "Page Url",
      "type" : "string",
      "pattern" : "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)",
      "minLength" : 1,
      "maxLength" : 1260
    },
    "Arn" : {
      "description" : "Resource ARN",
      "type" : "string",
      "pattern" : "arn:[^:]*:[^:]*:[^:]*:[^:]*:.*"
    },
    "Telemetry" : {
      "type" : "string",
      "enum" : [ "errors", "performance", "http" ]
    },
    "MetricDestination" : {
      "description" : "An structure which defines the destination and the metrics that you want to send.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Destination" : {
          "description" : "Defines the destination to send the metrics to. Valid values are CloudWatch and Evidently. Note: Evidently has been discontinued and is no longer supported - requests with Evidently will be rejected.",
          "type" : "string",
          "enum" : [ "CloudWatch", "Evidently" ]
        },
        "DestinationArn" : {
          "type" : "string",
          "pattern" : "arn:[^:]*:[^:]*:[^:]*:[^:]*:.*",
          "description" : "Evidently has been discontinued and therefore this is no longer an acceptable field. If Destination is CloudWatch, do not use this parameter. \n\nThis parameter specifies the ARN of the Evidently experiment that will receive the extended metrics."
        },
        "IamRoleArn" : {
          "type" : "string",
          "pattern" : "arn:[^:]*:[^:]*:[^:]*:[^:]*:.*",
          "description" : "Evidently has been discontinued and therefore this is no longer an acceptable field. If Destination is CloudWatch, do not use this parameter. \n\nThis parameter specifies the ARN of an IAM role that RUM will assume to write to the Evidently experiment that you are sending metrics to. This role must have permission to write to that experiment."
        },
        "MetricDefinitions" : {
          "description" : "An array of structures which define the metrics that you want to send.",
          "type" : "array",
          "uniqueItems" : true,
          "insertionOrder" : false,
          "minItems" : 0,
          "maxItems" : 2000,
          "items" : {
            "$ref" : "#/definitions/MetricDefinition"
          }
        }
      },
      "required" : [ "Destination" ]
    },
    "MetricDefinition" : {
      "description" : "A single metric definition",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name for the metric that is defined in this structure. For extended metrics, valid values are the following:\n\nPerformanceNavigationDuration\n\nPerformanceResourceDuration\n\nNavigationSatisfiedTransaction\n\nNavigationToleratedTransaction\n\nNavigationFrustratedTransaction\n\nWebVitalsCumulativeLayoutShift\n\nWebVitalsFirstInputDelay\n\nWebVitalsLargestContentfulPaint\n\nWebVitalsInteractionToNextPaint\n\nJsErrorCount\n\nHttpErrorCount\n\nSessionCount\n\nPageViewCount\n\nHttp4xxCount\n\nHttp5xxCount\n\nSessionDuration\n\nPageViewCountPerSession\n\nJsErrorCountPerSession\n\nHttp4xxCountPerSession\n\nHttp5xxCountPerSession\n\nJsErrorCountPerPageView\n\nHttp4xxCountPerPageView\n\nHttp5xxCountPerPageView\n\nTimeOnPage\n\nColdLaunchTime\n\nWarmLaunchTime\n\nCrashCount\n\nANRCount\n\nAppHangCount\n\nScreenLoadCount\n\nScreenLoadTime\n\nNetworkLatency\n\nSpanPayloadSize\n\nLogEventPayloadSize",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 255
        },
        "Namespace" : {
          "description" : "The namespace used by CloudWatch Metrics for the metric that is defined in this structure",
          "type" : "string",
          "pattern" : "[a-zA-Z0-9-._/#:]+$",
          "minLength" : 1,
          "maxLength" : 237
        },
        "ValueKey" : {
          "description" : "The field within the event object that the metric value is sourced from.\n\nIf you omit this field, a hardcoded value of 1 is pushed as the metric value. This is useful if you just want to count the number of events that the filter catches.\n\nIf this metric is sent to Evidently, this field will be passed to Evidently raw and Evidently will handle data extraction from the event. Note: Evidently has been discontinued.",
          "type" : "string",
          "pattern" : ".*",
          "minLength" : 1,
          "maxLength" : 256
        },
        "UnitLabel" : {
          "description" : "The CloudWatch metric unit to use for this metric. If you omit this field, the metric is recorded with no unit.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "DimensionKeys" : {
          "description" : "Use this field only if you are sending the metric to CloudWatch.\n\nThis field is a map of field paths to dimension names. It defines the dimensions to associate with this metric in CloudWatch. For extended metrics, valid values for the entries in this field are the following:\n\n\"metadata.pageId\": \"PageId\"\n\n\"metadata.browserName\": \"BrowserName\"\n\n\"metadata.deviceType\": \"DeviceType\"\n\n\"metadata.osName\": \"OSName\"\n\n\"metadata.countryCode\": \"CountryCode\"\n\n\"event_details.fileType\": \"FileType\"\n\nAll dimensions listed in this field must also be included in EventPattern.",
          "type" : "object",
          "patternProperties" : {
            "^(?!:).*[^\\s].*" : {
              "type" : "string",
              "pattern" : ".*[^\\s].*",
              "minLength" : 1,
              "maxLength" : 255
            }
          },
          "additionalProperties" : false
        },
        "EventPattern" : {
          "description" : "The pattern that defines the metric, specified as a JSON object. RUM checks events that happen in a user's session against the pattern, and events that match the pattern are sent to the metric destination.\n\nWhen you define extended metrics, the metric definition is not valid if EventPattern is omitted.\n\nExample event patterns:\n\n'{ \"event_type\": [\"com.amazon.rum.js_error_event\"], \"metadata\": { \"browserName\": [ \"Chrome\", \"Safari\" ], } }'\n\n'{ \"event_type\": [\"com.amazon.rum.performance_navigation_event\"], \"metadata\": { \"browserName\": [ \"Chrome\", \"Firefox\" ] }, \"event_details\": { \"duration\": [{ \"numeric\": [ \"<\", 2000 ] }] } }'\n\n'{ \"event_type\": [\"com.amazon.rum.performance_navigation_event\"], \"metadata\": { \"browserName\": [ \"Chrome\", \"Safari\" ], \"countryCode\": [ \"US\" ] }, \"event_details\": { \"duration\": [{ \"numeric\": [ \">=\", 2000, \"<\", 8000 ] }] } }'\n\nIf the metrics destination' is CloudWatch and the event also matches a value in DimensionKeys, then the metric is published with the specified dimensions.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 4000
        }
      },
      "required" : [ "Name" ]
    },
    "ResourcePolicy" : {
      "description" : "A structure that defines resource policy attached to your app monitor.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "PolicyDocument" : {
          "type" : "string",
          "description" : "The JSON to use as the resource policy. The document can be up to 4 KB in size. "
        },
        "PolicyRevisionId" : {
          "type" : "string",
          "description" : "A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy. \n\n When you assign a policy revision ID, then later requests about that policy will be rejected with an InvalidPolicyRevisionIdException error if they don't provide the correct current revision ID.",
          "minLength" : 1,
          "maxLength" : 255
        }
      },
      "required" : [ "PolicyDocument" ]
    },
    "CustomEventsStatus" : {
      "type" : "string",
      "enum" : [ "ENABLED", "DISABLED" ]
    },
    "CustomEvents" : {
      "description" : "AppMonitor custom events configuration",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Status" : {
          "description" : "Indicates whether AppMonitor accepts custom events.",
          "$ref" : "#/definitions/CustomEventsStatus"
        }
      }
    },
    "DeobfuscationConfiguration" : {
      "description" : "A structure that contains the configuration for how an app monitor can deobfuscate stack traces.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "JavaScriptSourceMaps" : {
          "description" : "A structure that contains the configuration for how an app monitor can unminify JavaScript error stack traces using source maps.",
          "additionalProperties" : false,
          "type" : "object",
          "properties" : {
            "Status" : {
              "description" : "Specifies whether JavaScript error stack traces should be unminified for this app monitor. The default is for JavaScript error stack trace unminification to be DISABLED",
              "type" : "string",
              "enum" : [ "ENABLED", "DISABLED" ]
            },
            "S3Uri" : {
              "description" : "The S3Uri of the bucket or folder that stores the source map files. It is required if status is ENABLED.",
              "type" : "string",
              "pattern" : "^s3://[a-z0-9][-.a-z0-9]{1,62}(?:/[-!_*'().a-z0-9A-Z]+(?:/[-!_*'().a-z0-9A-Z]+)*)?/?$"
            }
          },
          "required" : [ "Status" ]
        }
      }
    }
  },
  "properties" : {
    "Id" : {
      "description" : "The unique ID of the new app monitor.",
      "type" : "string",
      "pattern" : "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
      "minLength" : 36,
      "maxLength" : 36
    },
    "Name" : {
      "description" : "A name for the app monitor",
      "type" : "string",
      "pattern" : "[\\.\\-_/#A-Za-z0-9]+",
      "minLength" : 1,
      "maxLength" : 255
    },
    "Domain" : {
      "description" : "The top-level internet domain name for which your application has administrative authority. The CreateAppMonitor requires either the domain or the domain list.",
      "type" : "string",
      "pattern" : "^(localhost)$|^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|(?=^[a-zA-Z0-9\\.\\*-]{4,253}$)(?!.*\\.-)(?!.*-\\.)(?!.*\\.\\.)(?!.*[^\\.]{64,})^(\\*\\.)?(?![-\\.\\*])[^\\*]{1,}\\.(\\*|(?!.*--)(?=.*[a-zA-Z])[^\\*]{1,}[^\\*-])$",
      "minLength" : 1,
      "maxLength" : 253
    },
    "DomainList" : {
      "description" : "The top-level internet domain names for which your application has administrative authority. The CreateAppMonitor requires either the domain or the domain list.",
      "type" : "array",
      "minItems" : 1,
      "maxItems" : 5,
      "items" : {
        "type" : "string",
        "pattern" : "^(localhost)$|^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|(?=^[a-zA-Z0-9\\.\\*-]{4,253}$)(?!.*\\.-)(?!.*-\\.)(?!.*\\.\\.)(?!.*[^\\.]{64,})^(\\*\\.)?(?![-\\.\\*])[^\\*]{1,}\\.(\\*|(?!.*--)(?=.*[a-zA-Z])[^\\*]{1,}[^\\*-])$",
        "minLength" : 1,
        "maxLength" : 253
      }
    },
    "CwLogEnabled" : {
      "description" : "Data collected by RUM is kept by RUM for 30 days and then deleted. This parameter specifies whether RUM sends a copy of this telemetry data to CWLlong in your account. This enables you to keep the telemetry data for more than 30 days, but it does incur CWLlong charges. If you omit this parameter, the default is false",
      "type" : "boolean"
    },
    "Tags" : {
      "$ref" : "#/definitions/TagDef"
    },
    "AppMonitorConfiguration" : {
      "$ref" : "#/definitions/AppMonitorConfiguration"
    },
    "CustomEvents" : {
      "$ref" : "#/definitions/CustomEvents"
    },
    "ResourcePolicy" : {
      "$ref" : "#/definitions/ResourcePolicy"
    },
    "DeobfuscationConfiguration" : {
      "$ref" : "#/definitions/DeobfuscationConfiguration"
    },
    "Platform" : {
      "type" : "string",
      "enum" : [ "Web", "Android", "iOS" ]
    }
  },
  "additionalProperties" : false,
  "createOnlyProperties" : [ "/properties/Name", "/properties/Platform" ],
  "deprecatedProperties" : [ "/properties/AppMonitorConfiguration/MetricDestinations/*/DestinationArn", "/properties/AppMonitorConfiguration/MetricDestinations/*/IamRoleArn" ],
  "readOnlyProperties" : [ "/properties/Id" ],
  "primaryIdentifier" : [ "/properties/Name" ],
  "additionalIdentifiers" : [ [ "/properties/Id" ] ],
  "required" : [ "Name" ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "rum:UntagResource", "rum:TagResource", "rum:ListTagsForResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "rum:GetAppMonitor", "rum:CreateAppMonitor", "dynamodb:GetItem", "dynamodb:PutItem", "s3:GetObject", "s3:PutObject", "s3:GetObjectAcl", "s3:DoesObjectExist", "logs:CreateLogDelivery", "logs:CreateLogGroup", "logs:GetLogDelivery", "logs:UpdateLogDelivery", "logs:PutResourcePolicy", "logs:DescribeResourcePolicies", "logs:DescribeLogGroups", "logs:PutRetentionPolicy", "rum:TagResource", "rum:ListTagsForResource", "cognito-identity:DescribeIdentityPool", "iam:GetRole", "iam:CreateServiceLinkedRole", "iam:PassRole", "rum:PutRumMetricsDestination", "rum:BatchCreateRumMetricDefinitions", "rum:ListRumMetricsDestinations", "rum:BatchGetRumMetricDefinitions", "rum:GetResourcePolicy", "rum:PutResourcePolicy" ]
    },
    "read" : {
      "permissions" : [ "rum:GetAppMonitor", "dynamodb:GetItem", "s3:GetObject", "s3:DoesObjectExist", "s3:GetObjectAcl", "rum:ListTagsForResource", "rum:ListRumMetricsDestinations", "rum:BatchGetRumMetricDefinitions", "rum:GetResourcePolicy" ]
    },
    "update" : {
      "permissions" : [ "rum:GetAppMonitor", "rum:UpdateAppMonitor", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem", "dynamodb:Query", "s3:GetObject", "s3:PutObject", "s3:GetObjectAcl", "s3:DoesObjectExist", "logs:CreateLogDelivery", "logs:CreateLogGroup", "logs:GetLogDelivery", "logs:UpdateLogDelivery", "logs:PutResourcePolicy", "logs:DescribeResourcePolicies", "logs:DescribeLogGroups", "logs:PutRetentionPolicy", "rum:TagResource", "rum:UntagResource", "rum:ListTagsForResource", "iam:GetRole", "iam:CreateServiceLinkedRole", "iam:PassRole", "rum:PutRumMetricsDestination", "rum:DeleteRumMetricsDestination", "rum:ListRumMetricsDestinations", "rum:BatchCreateRumMetricDefinitions", "rum:BatchDeleteRumMetricDefinitions", "rum:BatchGetRumMetricDefinitions", "rum:UpdateRumMetricDefinition", "rum:GetResourcePolicy", "rum:PutResourcePolicy", "rum:DeleteResourcePolicy" ]
    },
    "delete" : {
      "permissions" : [ "rum:GetAppMonitor", "rum:DeleteAppMonitor", "dynamodb:DeleteItem", "dynamodb:Query", "logs:DeleteLogDelivery", "s3:DeleteObject", "s3:DoesObjectExist", "rum:UntagResource", "rum:ListTagsForResource", "rum:DeleteRumMetricsDestination", "rum:BatchDeleteRumMetricDefinitions", "rum:ListRumMetricsDestinations", "rum:BatchGetRumMetricDefinitions", "rum:GetResourcePolicy", "rum:PutResourcePolicy", "rum:DeleteResourcePolicy" ]
    },
    "list" : {
      "permissions" : [ "rum:ListAppMonitors", "dynamodb:DescribeTable", "rum:GetAppMonitor", "dynamodb:GetItem", "dynamodb:BatchGetItem", "dynamodb:Query", "s3:GetObject", "s3:DoesObjectExist", "s3:GetObjectAcl", "logs:DescribeLogGroups", "rum:ListTagsForResource" ]
    }
  }
}