CreateGameServerGroup - Amazon GameLift Service

CreateGameServerGroup

This operation is part of Amazon GameLift FleetIQ with game server groups, which is in preview release and is subject to change.

Creates a GameLift FleetIQ game server group to manage a collection of Amazon EC2 instances for game hosting. In addition to creating the game server group, this operation also creates an Auto Scaling group in your AWS account and establishes a link between the two groups. You have full control over configuration of the Auto Scaling group, but GameLift FleetIQ routinely updates certain Auto Scaling group properties in order to optimize the group's instances for low-cost game hosting. You can view the status of your game server groups in the GameLift console. Game server group metrics and events are emitted to Amazon CloudWatch.

Before creating a new game server group, you must set up the following:

  • An Amazon EC2 launch template. The template provides configuration settings for a set of Amazon EC2 instances and includes the game server build that you want to deploy and run on each instance. For more information on creating a launch template, see Launching an Instance from a Launch Template in the Amazon EC2 User Guide.

  • An IAM role. The role sets up limited access to your AWS account. This role allows GameLift FleetIQ to create and manage the Auto Scaling group, get instance data, and emit metrics and events to CloudWatch. For more information on setting up an IAM permissions policy with principal access for GameLift, see Specifying a Principal in a Policy in the Amazon S3 Developer Guide.

To create a new game server group, provide a name and specify the IAM role and Amazon EC2 launch template. You also need to provide a list of instance types to be used in the group. You must also set initial maximum and minimum limits on the group's instance count. You can optionally set an Auto Scaling policy with target tracking based on a GameLift FleetIQ metric.

Once the game server group and corresponding Auto Scaling group are created, you have full access to change the Auto Scaling group's configuration as needed. Keep in mind, however, that some properties are periodically updated by GameLift FleetIQ as it balances the group's instances based on availability and cost.

Learn more

GameLift FleetIQ Guide

Related operations

Request Syntax

{ "AutoScalingPolicy": { "EstimatedInstanceWarmup": number, "TargetTrackingConfiguration": { "TargetValue": number } }, "BalancingStrategy": "string", "GameServerGroupName": "string", "GameServerProtectionPolicy": "string", "InstanceDefinitions": [ { "InstanceType": "string", "WeightedCapacity": "string" } ], "LaunchTemplate": { "LaunchTemplateId": "string", "LaunchTemplateName": "string", "Version": "string" }, "MaxSize": number, "MinSize": number, "RoleArn": "string", "Tags": [ { "Key": "string", "Value": "string" } ], "VpcSubnets": [ "string" ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Note

In the following list, the required parameters are described first.

GameServerGroupName

An identifier for the new game server group. This value is used to generate unique ARN identifiers for the EC2 Auto Scaling group and the GameLift FleetIQ game server group. The name must be unique per Region per AWS account.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9-\.]+

Required: Yes

InstanceDefinitions

A set of EC2 instance types to use when creating instances in the group. The instance definitions must specify at least two different instance types that are supported by GameLift FleetIQ. For more information on instance types, see EC2 Instance Types in the Amazon EC2 User Guide.

Type: Array of InstanceDefinition objects

Array Members: Minimum number of 2 items. Maximum number of 20 items.

Required: Yes

LaunchTemplate

The EC2 launch template that contains configuration settings and game server code to be deployed to all instances in the game server group. You can specify the template using either the template name or ID. For help with creating a launch template, see Creating a Launch Template for an Auto Scaling Group in the Amazon EC2 Auto Scaling User Guide.

Type: LaunchTemplateSpecification object

Required: Yes

MaxSize

The maximum number of instances allowed in the EC2 Auto Scaling group. During automatic scaling events, GameLift FleetIQ and EC2 do not scale up the group above this maximum.

Type: Integer

Valid Range: Minimum value of 1.

Required: Yes

MinSize

The minimum number of instances allowed in the EC2 Auto Scaling group. During automatic scaling events, GameLift FleetIQ and EC2 do not scale down the group below this minimum. In production, this value should be set to at least 1.

Type: Integer

Valid Range: Minimum value of 0.

Required: Yes

RoleArn

The Amazon Resource Name (ARN) for an IAM role that allows Amazon GameLift to access your EC2 Auto Scaling groups. The submitted role is validated to ensure that it contains the necessary permissions for game server groups.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^arn:.*:role\/[\w+=,.@-]+

Required: Yes

AutoScalingPolicy

Configuration settings to define a scaling policy for the Auto Scaling group that is optimized for game hosting. The scaling policy uses the metric "PercentUtilizedGameServers" to maintain a buffer of idle game servers that can immediately accommodate new games and players. Once the game server and Auto Scaling groups are created, you can update the scaling policy settings directly using the Auto Scaling Groups console or APIs.

Type: GameServerGroupAutoScalingPolicy object

Required: No

BalancingStrategy

The fallback balancing method to use for the game server group when Spot Instances in a Region become unavailable or are not viable for game hosting. Once triggered, this method remains active until Spot Instances can once again be used. Method options include the following:

  • SPOT_ONLY - If Spot Instances are unavailable, the game server group provides no hosting capacity. No new instances are started. Existing nonviable Spot Instances are terminated (after current gameplay ends) and are not replaced.

  • SPOT_PREFERRED - If Spot Instances are unavailable, the game server group continues to provide hosting capacity by using On-Demand Instances. Existing nonviable Spot Instances are terminated (after current gameplay ends) and are replaced with new On-Demand Instances.

Type: String

Valid Values: SPOT_ONLY | SPOT_PREFERRED

Required: No

GameServerProtectionPolicy

A flag that indicates whether instances in the game server group are protected from early termination. Unprotected instances that have active game servers running might be terminated during a scale-down event, causing players to be dropped from the game. Protected instances cannot be terminated while there are active game servers running. An exception to this is Spot Instances, which can be terminated by AWS regardless of protection status. This property is set to NO_PROTECTION by default.

Type: String

Valid Values: NO_PROTECTION | FULL_PROTECTION

Required: No

Tags

A list of labels to assign to the new game server group resource. Tags are developer-defined key-value pairs. Tagging AWS resources is useful for resource management, access management, and cost allocation. For more information, see Tagging AWS Resources in the AWS General Reference. Once the resource is created, you can use TagResource, UntagResource, and ListTagsForResource to add, remove, and view tags, respectively. The maximum tag limit may be lower than stated. See the AWS General Reference for actual tagging limits.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 200 items.

Required: No

VpcSubnets

A list of virtual private cloud (VPC) subnets to use with instances in the game server group. By default, all GameLift FleetIQ-supported Availability Zones are used. You can use this parameter to specify VPCs that you've set up.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 20 items.

Length Constraints: Fixed length of 15.

Pattern: ^subnet-[0-9a-z]{8}$

Required: No

Response Syntax

{ "GameServerGroup": { "AutoScalingGroupArn": "string", "BalancingStrategy": "string", "CreationTime": number, "GameServerGroupArn": "string", "GameServerGroupName": "string", "GameServerProtectionPolicy": "string", "InstanceDefinitions": [ { "InstanceType": "string", "WeightedCapacity": "string" } ], "LastUpdatedTime": number, "RoleArn": "string", "Status": "string", "StatusReason": "string", "SuspendedActions": [ "string" ] } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

GameServerGroup

The newly created game server group object, including the new ARN value for the GameLift FleetIQ game server group and the object's status. The EC2 Auto Scaling group ARN is initially null, since the group has not yet been created. This value is added once the game server group status reaches ACTIVE.

Type: GameServerGroup object

Errors

For information about the errors that are common to all actions, see Common Errors.

ConflictException

The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.

HTTP Status Code: 400

InternalServiceException

The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

HTTP Status Code: 500

InvalidRequestException

One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

HTTP Status Code: 400

LimitExceededException

The requested operation would cause the resource to exceed the allowed service limit. Resolve the issue before retrying.

HTTP Status Code: 400

UnauthorizedException

The client failed authentication. Clients should not retry such requests.

HTTP Status Code: 400

Examples

Create a new game server group

This example creates a game server group and Auto Scaling group that deploys your game server to instances of two different types. This game server group is set up to use Spot Instances only. The request also triggers creation of a target-tracking Auto Scaling policy. Based on this policy, the Auto Scaling group will maintain approximately 75% game server utilization. This utilization leaves 25% of capacity idle to support sudden increases in player demand.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

Sample Request

{ "GameServerGroupName": "MegaFrogServers_NA", "RoleArn": "arn:aws:iam:123456789012::role/GameLiftGsgRole", "MaxSize": 1, "MinSize": 1000, "GameServerProtectionPolicy": "NO_PROTECTION", "BalancingStrategy": "SPOT_ONLY", "LaunchTemplate": { "LaunchTemplateId": "12345678", }, "InstanceDefinitions": [ {"InstanceType": "c5.xlarge"}, {"InstanceType": "m5.xlarge"} ], "AutoScalingPolicy": { "TargetTrackingConfiguration": { "TargetValue": 75 } } } CLI command: aws gamelift create-game-server-group \ --game-server-group-name MegaFrogServers_NA \ --role-arn arn:aws:iam::123456789012:role/GameLiftGSGRole \ --max-size 100 \ --min-size 1 \ --game-server-protection-policy NO_PROTECTION \ --balancing-strategy SPOT_ONLY --launch-template LaunchTemplateId=lt-012ab345cde6789ff \ --instance-definitions '[{"InstanceType": "c5.xlarge"}, {"InstanceType": "m5.xlarge"}]' \ --auto-scaling-policy '{"TargetTrackingConfiguration": {"TargetValue": 75}}'

Sample Response

{ "GameServerGroup": { "AutoScalingGroupArn": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:1111aaaa-22bb-33cc-44dd-5555eeee66ff:autoScalingGroupName/MegaFrogServers_NA", "BalancingStrategy": "SPOT_ONLY", "CreationTime": 1496365885.44, "GameServerGroupArn": "arn:aws:gamelift:us-west-2::GameServerGroup/MegaFrogServers_NA", "GameServerGroupName": " MegaFrogServers_NA", "GameServerProtectionPolicy": "NO_PROTECTION", "InstanceDefinitions": [ { "InstanceType": "c5.xlarge", "WeightedCapacity": "1" } { "InstanceType": "m5.xlarge", "WeightedCapacity": "1" } ], "LastUpdatedTime": 1496365885.44, "RoleArn": "arn:aws:iam:123456789012::role/GameLiftGsgRole", "Status": "NEW", "StatusReason": "", "SuspendedActions": [] }

Create a new game server group with weighted instances

This example creates a game server group with three weighted instance types. Because a balancing strategy is not defined in this example, the default "SPOT_PREFERRED" is used.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

Sample Request

{ "GameServerGroupName": "MegaFrogServers_NA", "RoleArn": "arn:aws:iam:123456789012::role/GameLiftGsgRole", "MaxSize": 1, "MinSize": 200, "InstanceDefinitions": [ { "InstanceType": "c5.2xlarge", "WeightedCapacity": "1" }, { "InstanceType": "c5.4xlarge", "WeightedCapacity": "2" }, { "InstanceType": "c5.24xlarge", "WeightedCapacity": "12" } ], "LaunchTemplate": { "LaunchTemplateName": "MegaFrogServers" } } CLI command: aws gamelift create-game-server-group \ --game-server-group-name MegaFrogServers_NA \ --role-arn arn:aws:iam:123456789012::role/GameLiftGsgRole \ --min-size 1 \ --max-size 200 \ --launch-template {"LaunchTemplateName": MegaFrogServers} \ --instance-definitions '[{"IntanceType":"m5.2xlarge","WeightedCapacity":"1"},{"InstanceType":"m5.4xlarge","WeightedCapacity":"2"},{"InstanceType":"m5.24xlarge","WeightedCapacity":"12"}]'

Sample Response

{ "GameServerGroup": { "AutoScalingGroupArn": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:1111aaaa-22bb-33cc-44dd-5555eeee66ff:autoScalingGroupName/MegaFrogServers_NA", "BalancingStrategy": "SPOT_PREFERRED", "CreationTime": 1496365885.44, "GameServerGroupArn": "arn:aws:gamelift:us-west-2::GameServerGroup/MegaFrogServers_NA", "GameServerGroupName": " MegaFrogServers_NA", "GameServerProtectionPolicy": "NO_PROTECTION", "InstanceDefinitions": [ { "InstanceType": "c5.2xlarge", "WeightedCapacity": "1" }, { "InstanceType": "c5.4xlarge", "WeightedCapacity": "2" }, { "InstanceType": "c5.24xlarge", "WeightedCapacity": "12" } ], "LastUpdatedTime": 1496365885.44, "RoleArn": "arn:aws:iam:123456789012::role/GameLiftGsgRole", "Status": "NEW", "StatusReason": "", "SuspendedActions": [] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: