{
  "typeName" : "AWS::GreengrassV2::Deployment",
  "description" : "Resource for Greengrass V2 deployment.",
  "definitions" : {
    "ComponentDeploymentSpecification" : {
      "type" : "object",
      "properties" : {
        "ComponentVersion" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 64
        },
        "ConfigurationUpdate" : {
          "$ref" : "#/definitions/ComponentConfigurationUpdate"
        },
        "RunWith" : {
          "$ref" : "#/definitions/ComponentRunWith"
        }
      },
      "additionalProperties" : false
    },
    "SystemResourceLimits" : {
      "type" : "object",
      "properties" : {
        "Memory" : {
          "type" : "integer",
          "format" : "int64",
          "minimum" : 0,
          "maximum" : 9223372036854771712
        },
        "Cpus" : {
          "type" : "number",
          "minimum" : 0
        }
      },
      "additionalProperties" : false
    },
    "ComponentRunWith" : {
      "type" : "object",
      "properties" : {
        "PosixUser" : {
          "type" : "string",
          "minLength" : 1
        },
        "SystemResourceLimits" : {
          "$ref" : "#/definitions/SystemResourceLimits"
        },
        "WindowsUser" : {
          "type" : "string",
          "minLength" : 1
        }
      },
      "additionalProperties" : false
    },
    "ComponentConfigurationUpdate" : {
      "type" : "object",
      "properties" : {
        "Merge" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 10485760
        },
        "Reset" : {
          "type" : "array",
          "items" : {
            "type" : "string",
            "minLength" : 0,
            "maxLength" : 256
          },
          "insertionOrder" : false
        }
      },
      "additionalProperties" : false
    },
    "DeploymentIoTJobConfiguration" : {
      "type" : "object",
      "properties" : {
        "JobExecutionsRolloutConfig" : {
          "$ref" : "#/definitions/IoTJobExecutionsRolloutConfig"
        },
        "AbortConfig" : {
          "$ref" : "#/definitions/IoTJobAbortConfig"
        },
        "TimeoutConfig" : {
          "$ref" : "#/definitions/IoTJobTimeoutConfig"
        }
      },
      "additionalProperties" : false
    },
    "IoTJobExecutionsRolloutConfig" : {
      "type" : "object",
      "properties" : {
        "ExponentialRate" : {
          "$ref" : "#/definitions/IoTJobExponentialRolloutRate"
        },
        "MaximumPerMinute" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 1000
        }
      },
      "additionalProperties" : false
    },
    "IoTJobAbortConfig" : {
      "type" : "object",
      "properties" : {
        "CriteriaList" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/IoTJobAbortCriteria"
          },
          "minItems" : 1,
          "insertionOrder" : false
        }
      },
      "required" : [ "CriteriaList" ],
      "additionalProperties" : false
    },
    "IoTJobAbortCriteria" : {
      "type" : "object",
      "properties" : {
        "FailureType" : {
          "type" : "string",
          "enum" : [ "FAILED", "REJECTED", "TIMED_OUT", "ALL" ]
        },
        "Action" : {
          "type" : "string",
          "enum" : [ "CANCEL" ]
        },
        "ThresholdPercentage" : {
          "type" : "number",
          "minimum" : 0,
          "maximum" : 100
        },
        "MinNumberOfExecutedThings" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 2147483647
        }
      },
      "required" : [ "FailureType", "Action", "ThresholdPercentage", "MinNumberOfExecutedThings" ],
      "additionalProperties" : false
    },
    "IoTJobTimeoutConfig" : {
      "type" : "object",
      "properties" : {
        "InProgressTimeoutInMinutes" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 2147483647
        }
      },
      "additionalProperties" : false
    },
    "IoTJobExponentialRolloutRate" : {
      "type" : "object",
      "properties" : {
        "BaseRatePerMinute" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 1000
        },
        "IncrementFactor" : {
          "type" : "number",
          "minimum" : 1,
          "maximum" : 5
        },
        "RateIncreaseCriteria" : {
          "$ref" : "#/definitions/IoTJobRateIncreaseCriteria"
        }
      },
      "required" : [ "BaseRatePerMinute", "IncrementFactor", "RateIncreaseCriteria" ],
      "additionalProperties" : false
    },
    "IoTJobRateIncreaseCriteria" : {
      "type" : "object",
      "oneOf" : [ {
        "type" : "object",
        "additionalProperties" : false,
        "properties" : {
          "NumberOfNotifiedThings" : {
            "$ref" : "#/definitions/NumberOfThings"
          }
        }
      }, {
        "type" : "object",
        "additionalProperties" : false,
        "properties" : {
          "NumberOfSucceededThings" : {
            "$ref" : "#/definitions/NumberOfThings"
          }
        }
      } ]
    },
    "NumberOfThings" : {
      "type" : "integer",
      "minimum" : 1,
      "maximum" : 2147483647
    },
    "DeploymentPolicies" : {
      "type" : "object",
      "properties" : {
        "FailureHandlingPolicy" : {
          "type" : "string",
          "enum" : [ "ROLLBACK", "DO_NOTHING" ]
        },
        "ComponentUpdatePolicy" : {
          "$ref" : "#/definitions/DeploymentComponentUpdatePolicy"
        },
        "ConfigurationValidationPolicy" : {
          "$ref" : "#/definitions/DeploymentConfigurationValidationPolicy"
        }
      },
      "additionalProperties" : false
    },
    "DeploymentComponentUpdatePolicy" : {
      "type" : "object",
      "properties" : {
        "TimeoutInSeconds" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 2147483647
        },
        "Action" : {
          "type" : "string",
          "enum" : [ "NOTIFY_COMPONENTS", "SKIP_NOTIFY_COMPONENTS" ]
        }
      },
      "additionalProperties" : false
    },
    "DeploymentConfigurationValidationPolicy" : {
      "type" : "object",
      "properties" : {
        "TimeoutInSeconds" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 2147483647
        }
      },
      "additionalProperties" : false
    }
  },
  "properties" : {
    "TargetArn" : {
      "type" : "string",
      "pattern" : "arn:[^:]*:iot:[^:]*:[0-9]+:(thing|thinggroup)/.+"
    },
    "ParentTargetArn" : {
      "type" : "string",
      "pattern" : "arn:[^:]*:iot:[^:]*:[0-9]+:thinggroup/.+"
    },
    "DeploymentId" : {
      "type" : "string",
      "pattern" : ".+"
    },
    "DeploymentName" : {
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 256
    },
    "Components" : {
      "type" : "object",
      "patternProperties" : {
        ".+" : {
          "$ref" : "#/definitions/ComponentDeploymentSpecification"
        }
      },
      "additionalProperties" : false
    },
    "IotJobConfiguration" : {
      "$ref" : "#/definitions/DeploymentIoTJobConfiguration"
    },
    "DeploymentPolicies" : {
      "$ref" : "#/definitions/DeploymentPolicies"
    },
    "Tags" : {
      "type" : "object",
      "patternProperties" : {
        ".*" : {
          "type" : "string",
          "maxLength" : 256
        }
      },
      "maxProperties" : 200,
      "additionalProperties" : false
    }
  },
  "required" : [ "TargetArn" ],
  "primaryIdentifier" : [ "/properties/DeploymentId" ],
  "additionalProperties" : false,
  "readOnlyProperties" : [ "/properties/DeploymentId" ],
  "createOnlyProperties" : [ "/properties/TargetArn", "/properties/ParentTargetArn", "/properties/DeploymentName", "/properties/Components", "/properties/IotJobConfiguration", "/properties/DeploymentPolicies" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "greengrass:CreateDeployment", "greengrass:GetDeployment", "greengrass:TagResource", "iot:CancelJob", "iot:CreateJob", "iot:DeleteThingShadow", "iot:DescribeJob", "iot:DescribeThing", "iot:DescribeThingGroup", "iot:GetThingShadow", "iot:UpdateJob", "iot:UpdateThingShadow" ]
    },
    "read" : {
      "permissions" : [ "greengrass:GetDeployment", "iot:DescribeJob", "iot:DescribeThing", "iot:DescribeThingGroup", "iot:GetThingShadow" ]
    },
    "update" : {
      "permissions" : [ "greengrass:GetDeployment", "greengrass:TagResource", "greengrass:UntagResource", "iot:DescribeJob" ]
    },
    "delete" : {
      "permissions" : [ "greengrass:DeleteDeployment", "greengrass:CancelDeployment", "iot:CancelJob", "iot:DeleteJob", "iot:DescribeJob" ]
    },
    "list" : {
      "permissions" : [ "greengrass:ListDeployments", "iot:DescribeJob", "iot:DescribeThing", "iot:DescribeThingGroup", "iot:GetThingShadow" ]
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "greengrass:TagResource", "greengrass:UntagResource", "greengrass:ListTagsForResource" ]
  }
}