{
  "$schema" : "https://schema.cloudformation.us-east-1.amazonaws.com/provider.definition.schema.v1.json",
  "typeName" : "AWS::GameLift::ContainerFleet",
  "description" : "The AWS::GameLift::ContainerFleet resource creates an Amazon GameLift (GameLift) container fleet to host game servers.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-gamelift.git",
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "gamelift:ListTagsForResource", "gamelift:TagResource", "gamelift:UntagResource" ]
  },
  "definitions" : {
    "ConnectionPortRange" : {
      "description" : "Defines the range of ports on the instance that allow inbound traffic to connect with containers in a fleet.",
      "type" : "object",
      "properties" : {
        "FromPort" : {
          "description" : "A starting value for a range of allowed port numbers.",
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 60000
        },
        "ToPort" : {
          "description" : "An ending value for a range of allowed port numbers. Port numbers are end-inclusive. This value must be higher than FromPort.",
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 60000
        }
      },
      "additionalProperties" : false,
      "required" : [ "FromPort", "ToPort" ]
    },
    "IpPermission" : {
      "description" : "A range of IP addresses and port settings that allow inbound traffic to connect to server processes on an Amazon GameLift hosting resource. New game sessions that are started on the fleet are assigned an IP address/port number combination, which must fall into the fleet's allowed ranges. For fleets created with a custom game server, the ranges reflect the server's game session assignments. For Realtime Servers fleets, Amazon GameLift automatically opens two port ranges, one for TCP messaging and one for UDP, for use by the Realtime servers.",
      "type" : "object",
      "properties" : {
        "FromPort" : {
          "description" : "A starting value for a range of allowed port numbers.",
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 60000
        },
        "IpRange" : {
          "description" : "A range of allowed IP addresses. This value must be expressed in CIDR notation. Example: \"000.000.000.000/[subnet mask]\" or optionally the shortened version \"0.0.0.0/[subnet mask]\".",
          "type" : "string",
          "pattern" : "(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(/([0-9]|[1-2][0-9]|3[0-2]))$)"
        },
        "Protocol" : {
          "description" : "The network communication protocol used by the fleet.",
          "type" : "string",
          "enum" : [ "TCP", "UDP" ]
        },
        "ToPort" : {
          "description" : "An ending value for a range of allowed port numbers. Port numbers are end-inclusive. This value must be higher than FromPort.",
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 60000
        }
      },
      "additionalProperties" : false,
      "required" : [ "FromPort", "IpRange", "Protocol", "ToPort" ]
    },
    "GameSessionCreationLimitPolicy" : {
      "description" : "A policy that limits the number of game sessions a player can create on the same fleet. This optional policy gives game owners control over how players can consume available game server resources. A resource creation policy makes the following statement: \"An individual player can create a maximum number of new game sessions within a specified time period\".\n\nThe policy is evaluated when a player tries to create a new game session. For example, assume you have a policy of 10 new game sessions and a time period of 60 minutes. On receiving a CreateGameSession request, Amazon GameLift checks that the player (identified by CreatorId) has created fewer than 10 game sessions in the past 60 minutes.",
      "type" : "object",
      "properties" : {
        "NewGameSessionsPerCreator" : {
          "description" : "The maximum number of game sessions that an individual can create during the policy period.",
          "type" : "integer",
          "minimum" : 0
        },
        "PolicyPeriodInMinutes" : {
          "description" : "The time span used in evaluating the resource creation limit policy.",
          "type" : "integer",
          "minimum" : 0
        }
      },
      "additionalProperties" : false
    },
    "LogDestination" : {
      "description" : "Configures the service that provides logs.",
      "type" : "string",
      "enum" : [ "NONE", "CLOUDWATCH", "S3" ]
    },
    "LogConfiguration" : {
      "description" : "A policy the location and provider of logs from the fleet.",
      "type" : "object",
      "properties" : {
        "LogDestination" : {
          "$ref" : "#/definitions/LogDestination"
        },
        "LogGroupArn" : {
          "description" : "If log destination is CLOUDWATCH, logs are sent to the specified log group in Amazon CloudWatch.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 512,
          "pattern" : "[a-zA-Z0-9:/\\-\\*]+"
        },
        "S3BucketName" : {
          "description" : "The name of the S3 bucket to pull logs from if S3 is the LogDestination",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 1024
        }
      },
      "additionalProperties" : false
    },
    "Location" : {
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 64,
      "pattern" : "^[A-Za-z0-9\\-]+"
    },
    "LocationCapacity" : {
      "description" : "Current resource capacity settings in a specified fleet or location. The location value might refer to a fleet's remote location or its home Region.",
      "type" : "object",
      "properties" : {
        "DesiredEC2Instances" : {
          "description" : "Defaults to MinSize if not defined. The number of EC2 instances you want to maintain in the specified fleet location. This value must fall between the minimum and maximum size limits. If any auto-scaling policy is defined for the container fleet, the desired instance will only be applied once during fleet creation and will be ignored in updates to avoid conflicts with auto-scaling. During updates with any auto-scaling policy defined, if current desired instance is lower than the new MinSize, it will be increased to the new MinSize; if current desired instance is larger than the new MaxSize, it will be decreased to the new MaxSize.",
          "type" : "integer",
          "minimum" : 0
        },
        "MinSize" : {
          "description" : "The minimum value allowed for the fleet's instance count for a location.",
          "type" : "integer",
          "minimum" : 0
        },
        "MaxSize" : {
          "description" : "The maximum value that is allowed for the fleet's instance count for a location.",
          "type" : "integer",
          "minimum" : 0
        },
        "ManagedCapacityConfiguration" : {
          "description" : "Configuration options for Amazon GameLift Servers-managed capacity behavior.",
          "$ref" : "#/definitions/ManagedCapacityConfiguration"
        }
      },
      "additionalProperties" : false,
      "required" : [ "MaxSize" ]
    },
    "LocationConfiguration" : {
      "description" : "A remote location where a multi-location fleet can deploy EC2 instances for game hosting.",
      "type" : "object",
      "properties" : {
        "Location" : {
          "$ref" : "#/definitions/Location"
        },
        "LocationCapacity" : {
          "$ref" : "#/definitions/LocationCapacity"
        },
        "StoppedActions" : {
          "$ref" : "#/definitions/StoppedActions"
        },
        "PlayerGatewayStatus" : {
          "description" : "The player gateway status for the location.",
          "type" : "string",
          "enum" : [ "DISABLED", "ENABLED" ]
        }
      },
      "additionalProperties" : false,
      "required" : [ "Location" ]
    },
    "ManagedCapacityConfiguration" : {
      "description" : "Configuration options for Amazon GameLift Servers managed capacity behavior.",
      "type" : "object",
      "properties" : {
        "ZeroCapacityStrategy" : {
          "description" : "The strategy Amazon GameLift Servers will use to automatically scale your capacity to and from zero in response to game session activity. Game session activity refers to any active running sessions or game session requests. When set to SCALE_TO_AND_FROM_ZERO, MinSize must not be specified and will be managed automatically. When set to MANUAL, MinSize is required.",
          "type" : "string",
          "enum" : [ "SCALE_TO_AND_FROM_ZERO", "MANUAL" ]
        },
        "ScaleInAfterInactivityMinutes" : {
          "description" : "Length of time, in minutes, that Amazon GameLift Servers will wait before scaling in your MinSize and DesiredInstances to 0 after a period with no game session activity.",
          "type" : "integer",
          "minimum" : 5,
          "maximum" : 1440
        }
      },
      "additionalProperties" : false,
      "required" : [ "ZeroCapacityStrategy" ]
    },
    "ScalingPolicy" : {
      "description" : "Rule that controls how a fleet is scaled. Scaling policies are uniquely identified by the combination of name and fleet ID.",
      "type" : "object",
      "properties" : {
        "ComparisonOperator" : {
          "description" : "Comparison operator to use when measuring a metric against the threshold value.",
          "type" : "string",
          "enum" : [ "GreaterThanOrEqualToThreshold", "GreaterThanThreshold", "LessThanThreshold", "LessThanOrEqualToThreshold" ]
        },
        "EvaluationPeriods" : {
          "description" : "Length of time (in minutes) the metric must be at or beyond the threshold before a scaling event is triggered.",
          "type" : "integer",
          "minimum" : 1
        },
        "MetricName" : {
          "description" : "Name of the Amazon GameLift-defined metric that is used to trigger a scaling adjustment.",
          "type" : "string",
          "enum" : [ "ActivatingGameSessions", "ActiveGameSessions", "ActiveInstances", "AvailableGameSessions", "AvailablePlayerSessions", "CurrentPlayerSessions", "IdleInstances", "PercentAvailableGameSessions", "PercentIdleInstances", "QueueDepth", "WaitTime", "ConcurrentActivatableGameSessions" ]
        },
        "Name" : {
          "description" : "A descriptive label that is associated with a fleet's scaling policy. Policy names do not need to be unique.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 1024
        },
        "PolicyType" : {
          "description" : "The type of scaling policy to create. For a target-based policy, set the parameter MetricName to 'PercentAvailableGameSessions' and specify a TargetConfiguration. For a rule-based policy set the following parameters: MetricName, ComparisonOperator, Threshold, EvaluationPeriods, ScalingAdjustmentType, and ScalingAdjustment.",
          "type" : "string",
          "enum" : [ "RuleBased", "TargetBased" ]
        },
        "ScalingAdjustment" : {
          "description" : "Amount of adjustment to make, based on the scaling adjustment type.",
          "type" : "integer"
        },
        "ScalingAdjustmentType" : {
          "description" : "The type of adjustment to make to a fleet's instance count.",
          "type" : "string",
          "enum" : [ "ChangeInCapacity", "ExactCapacity", "PercentChangeInCapacity" ]
        },
        "TargetConfiguration" : {
          "description" : "An object that contains settings for a target-based scaling policy.",
          "$ref" : "#/definitions/TargetConfiguration"
        },
        "Threshold" : {
          "description" : "Metric value used to trigger a scaling event.",
          "type" : "number"
        }
      },
      "additionalProperties" : false,
      "required" : [ "MetricName", "Name" ]
    },
    "StoppedActions" : {
      "description" : "A list of fleet actions that have been suspended in the fleet location.",
      "type" : "array",
      "maxItems" : 1,
      "items" : {
        "type" : "string",
        "enum" : [ "AUTO_SCALING" ]
      },
      "insertionOrder" : false
    },
    "TargetConfiguration" : {
      "description" : "Settings for a target-based scaling policy. A target-based policy tracks a particular fleet metric specifies a target value for the metric. As player usage changes, the policy triggers Amazon GameLift to adjust capacity so that the metric returns to the target value. The target configuration specifies settings as needed for the target based policy, including the target value.",
      "type" : "object",
      "properties" : {
        "TargetValue" : {
          "description" : "Desired value to use with a target-based scaling policy. The value must be relevant for whatever metric the scaling policy is using. For example, in a policy using the metric PercentAvailableGameSessions, the target value should be the preferred size of the fleet's buffer (the percent of capacity that should be idle and ready for new game sessions).",
          "type" : "number"
        }
      },
      "additionalProperties" : false,
      "required" : [ "TargetValue" ]
    },
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "description" : "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length.",
          "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.",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "DeploymentDetails" : {
      "description" : "Provides information about the last deployment ID and its status.",
      "type" : "object",
      "properties" : {
        "LatestDeploymentId" : {
          "description" : "The ID of the last deployment on the container fleet. This field will be empty if the container fleet does not have a ContainerGroupDefinition attached.",
          "type" : "string",
          "maxLength" : 1024,
          "pattern" : "^[a-zA-Z0-9\\-]+$|^$"
        }
      },
      "required" : [ ],
      "additionalProperties" : false
    },
    "DeploymentConfiguration" : {
      "description" : "Provides details about how to drain old tasks and replace them with new updated tasks.",
      "type" : "object",
      "properties" : {
        "ProtectionStrategy" : {
          "description" : "The protection strategy for deployment on the container fleet; defaults to WITH_PROTECTION.",
          "type" : "string",
          "enum" : [ "WITH_PROTECTION", "IGNORE_PROTECTION" ]
        },
        "MinimumHealthyPercentage" : {
          "description" : "The minimum percentage of healthy required; defaults to 75.",
          "type" : "integer",
          "minimum" : 30,
          "maximum" : 75
        },
        "ImpairmentStrategy" : {
          "description" : "The strategy to apply in case of impairment; defaults to MAINTAIN.",
          "type" : "string",
          "enum" : [ "MAINTAIN", "ROLLBACK" ]
        }
      },
      "required" : [ ],
      "additionalProperties" : false
    }
  },
  "properties" : {
    "FleetId" : {
      "description" : "Unique fleet ID",
      "type" : "string",
      "pattern" : "^[a-z]*fleet-[a-zA-Z0-9\\-]+",
      "minLength" : 1,
      "maxLength" : 128
    },
    "FleetRoleArn" : {
      "description" : "A unique identifier for an AWS IAM role that manages access to your AWS services. Create a role or look up a role's ARN from the IAM dashboard in the AWS Management Console.",
      "type" : "string",
      "pattern" : "^arn:aws(-.*)?:[a-z-]+:(([a-z]+-)+[0-9])?:([0-9]{12})?:[^.]+$",
      "minLength" : 1,
      "maxLength" : 256
    },
    "Description" : {
      "description" : "A human-readable description of a fleet.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 1024
    },
    "GameServerContainerGroupDefinitionName" : {
      "description" : "The name of the container group definition that will be created per game server. You must specify GAME_SERVER container group. You have the option to also specify one PER_INSTANCE container group.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 512,
      "pattern" : "^[a-zA-Z0-9\\-]+$|^arn:.*:containergroupdefinition\\/[a-zA-Z0-9\\-]+(:[0-9]+)?$"
    },
    "GameServerContainerGroupDefinitionArn" : {
      "description" : "The Amazon Resource Name (ARN) of the game server container group definition. This field will be empty if GameServerContainerGroupDefinitionName is not specified.",
      "type" : "string",
      "maxLength" : 512,
      "pattern" : "^arn:.*:containergroupdefinition\\/[a-zA-Z0-9\\-]+(:[0-9]+)?$|^$"
    },
    "PerInstanceContainerGroupDefinitionName" : {
      "description" : "The name of the container group definition that will be created per instance. This field is optional if you specify GameServerContainerGroupDefinitionName.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 512,
      "pattern" : "^[a-zA-Z0-9\\-]+$|^arn:.*:containergroupdefinition\\/[a-zA-Z0-9\\-]+(:[0-9]+)?$"
    },
    "PerInstanceContainerGroupDefinitionArn" : {
      "description" : "The Amazon Resource Name (ARN) of the per instance container group definition. This field will be empty if PerInstanceContainerGroupDefinitionName is not specified.",
      "type" : "string",
      "maxLength" : 512,
      "pattern" : "^arn:.*:containergroupdefinition\\/[a-zA-Z0-9\\-]+(:[0-9]+)?$|^$"
    },
    "InstanceConnectionPortRange" : {
      "$ref" : "#/definitions/ConnectionPortRange"
    },
    "InstanceInboundPermissions" : {
      "description" : "A range of IP addresses and port settings that allow inbound traffic to connect to server processes on an Amazon GameLift server.",
      "type" : "array",
      "maxItems" : 50,
      "items" : {
        "$ref" : "#/definitions/IpPermission"
      },
      "insertionOrder" : false
    },
    "GameServerContainerGroupsPerInstance" : {
      "description" : "The number of desired game server container groups per instance, a number between 1-5000.",
      "type" : "integer",
      "minimum" : 1,
      "maximum" : 5000
    },
    "MaximumGameServerContainerGroupsPerInstance" : {
      "description" : "The maximum number of game server container groups per instance, a number between 1-5000.",
      "type" : "integer",
      "minimum" : 1,
      "maximum" : 5000
    },
    "CreationTime" : {
      "description" : "A time stamp indicating when this data object was created. Format is a number expressed in Unix time as milliseconds (for example \"1469498468.057\").",
      "type" : "string"
    },
    "Status" : {
      "description" : "The current status of the container fleet.",
      "type" : "string",
      "enum" : [ "PENDING", "CREATING", "CREATED", "ACTIVATING", "ACTIVE", "UPDATING", "DELETING" ]
    },
    "DeploymentDetails" : {
      "$ref" : "#/definitions/DeploymentDetails"
    },
    "DeploymentConfiguration" : {
      "$ref" : "#/definitions/DeploymentConfiguration"
    },
    "InstanceType" : {
      "description" : "The name of an EC2 instance type that is supported in Amazon GameLift. A fleet instance type determines the computing resources of each instance in the fleet, including CPU, memory, storage, and networking capacity. Amazon GameLift supports the following EC2 instance types. See Amazon EC2 Instance Types for detailed descriptions.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 1024
    },
    "BillingType" : {
      "description" : "Indicates whether to use On-Demand instances or Spot instances for this fleet. If empty, the default is ON_DEMAND. Both categories of instances use identical hardware and configurations based on the instance type selected for this fleet.",
      "type" : "string",
      "enum" : [ "ON_DEMAND", "SPOT" ]
    },
    "Locations" : {
      "type" : "array",
      "maxItems" : 100,
      "items" : {
        "$ref" : "#/definitions/LocationConfiguration"
      },
      "insertionOrder" : false
    },
    "ScalingPolicies" : {
      "description" : "A list of rules that control how a fleet is scaled.",
      "type" : "array",
      "maxItems" : 50,
      "items" : {
        "$ref" : "#/definitions/ScalingPolicy"
      },
      "insertionOrder" : false
    },
    "MetricGroups" : {
      "description" : "The name of an Amazon CloudWatch metric group. A metric group aggregates the metrics for all fleets in the group. Specify a string containing the metric group name. You can use an existing name or use a new name to create a new metric group. Currently, this parameter can have only one string.",
      "type" : "array",
      "maxItems" : 1,
      "items" : {
        "type" : "string"
      },
      "insertionOrder" : false
    },
    "NewGameSessionProtectionPolicy" : {
      "description" : "A game session protection policy to apply to all game sessions hosted on instances in this fleet. When protected, active game sessions cannot be terminated during a scale-down event. If this parameter is not set, instances in this fleet default to no protection. You can change a fleet's protection policy to affect future game sessions on the fleet. You can also set protection for individual game sessions.",
      "type" : "string",
      "enum" : [ "FullProtection", "NoProtection" ]
    },
    "GameSessionCreationLimitPolicy" : {
      "description" : "A policy that limits the number of game sessions an individual player can create over a span of time for this fleet.",
      "$ref" : "#/definitions/GameSessionCreationLimitPolicy"
    },
    "LogConfiguration" : {
      "$ref" : "#/definitions/LogConfiguration"
    },
    "Tags" : {
      "description" : "An array of key-value pairs to apply to this resource.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "maxItems" : 200,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "PlayerGatewayMode" : {
      "description" : "The player gateway mode for the container fleet.",
      "type" : "string",
      "enum" : [ "DISABLED", "ENABLED", "REQUIRED" ]
    },
    "FleetArn" : {
      "description" : "The Amazon Resource Name (ARN) that is assigned to a Amazon GameLift container fleet resource and uniquely identifies it across all AWS Regions.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 512,
      "pattern" : "^arn:.*:[a-z]*fleet\\/[a-z]*fleet-[a-zA-Z0-9\\-]+$"
    }
  },
  "additionalProperties" : false,
  "required" : [ "FleetRoleArn" ],
  "createOnlyProperties" : [ "/properties/InstanceType", "/properties/BillingType", "/properties/PlayerGatewayMode" ],
  "readOnlyProperties" : [ "/properties/CreationTime", "/properties/Status", "/properties/FleetId", "/properties/FleetArn", "/properties/DeploymentDetails", "/properties/GameServerContainerGroupDefinitionArn", "/properties/PerInstanceContainerGroupDefinitionArn", "/properties/MaximumGameServerContainerGroupsPerInstance", "/properties/Locations/*/PlayerGatewayStatus" ],
  "writeOnlyProperties" : [ "/properties/DeploymentConfiguration", "/properties/GameServerContainerGroupDefinitionName", "/properties/PerInstanceContainerGroupDefinitionName" ],
  "primaryIdentifier" : [ "/properties/FleetId" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "gamelift:CreateContainerFleet", "gamelift:DescribeContainerFleet", "gamelift:DescribeFleetDeployment", "gamelift:DescribeFleetLocationAttributes", "gamelift:DescribeFleetLocationCapacity", "gamelift:DescribeScalingPolicies", "gamelift:ListTagsForResource", "gamelift:PutScalingPolicy", "gamelift:StopFleetActions", "gamelift:TagResource", "gamelift:UpdateFleetCapacity", "iam:PassRole" ]
    },
    "read" : {
      "permissions" : [ "gamelift:DescribeContainerFleet", "gamelift:DescribeFleetLocationAttributes", "gamelift:DescribeFleetLocationCapacity", "gamelift:DescribeScalingPolicies", "gamelift:ListTagsForResource" ]
    },
    "delete" : {
      "permissions" : [ "gamelift:DeleteContainerFleet", "gamelift:DescribeContainerFleet" ]
    },
    "list" : {
      "permissions" : [ "gamelift:ListContainerFleets" ]
    },
    "update" : {
      "permissions" : [ "gamelift:CreateFleetLocations", "gamelift:DeleteFleetLocations", "gamelift:DeleteScalingPolicy", "gamelift:DescribeContainerFleet", "gamelift:DescribeFleetDeployment", "gamelift:DescribeFleetLocationAttributes", "gamelift:DescribeFleetLocationCapacity", "gamelift:DescribeScalingPolicies", "gamelift:ListTagsForResource", "gamelift:PutScalingPolicy", "gamelift:StartFleetActions", "gamelift:StopFleetActions", "gamelift:TagResource", "gamelift:UntagResource", "gamelift:UpdateContainerFleet", "gamelift:UpdateFleetCapacity", "iam:PassRole" ]
    }
  }
}