GameServerGroup

class aws_cdk.aws_gamelift_alpha.GameServerGroup(scope, id, *, game_server_group_name, instance_definitions, launch_template, vpc, auto_scaling_policy=None, balancing_strategy=None, delete_option=None, max_size=None, min_size=None, protect_game_server=None, role=None, vpc_subnets=None)

Bases: GameServerGroupBase

(experimental) Creates a GameLift FleetIQ game server group for managing game hosting on a collection of Amazon EC2 instances for game hosting.

This operation creates the game server group, creates an Auto Scaling group in your AWS account, and establishes a link between the two groups. 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 have the following:

  • An Amazon EC2 launch template that specifies how to launch Amazon EC2 instances with your game server build.

  • An IAM role that extends limited access to your AWS account to allow GameLift FleetIQ to create and interact with the Auto Scaling group.

To create a new game server group, specify a unique group name, IAM role and Amazon EC2 launch template, and provide a list of instance types that can 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. Several properties that are set when creating a game server group, including maximum/minimum size and auto-scaling policy settings, must be updated directly in the Auto Scaling group. Keep in mind that some Auto Scaling group properties are periodically updated by GameLift FleetIQ as part of its balancing activities to optimize for availability and cost.

See:

https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html

Stability:

experimental

Resource:

AWS::GameLift::GameServerGroup

ExampleMetadata:

infused

Example:

# launch_template: ec2.ILaunchTemplate
# vpc: ec2.IVpc


gamelift.GameServerGroup(self, "GameServerGroup",
    game_server_group_name="sample-gameservergroup-name",
    instance_definitions=[gamelift.InstanceDefinition(
        instance_type=ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE)
    ), gamelift.InstanceDefinition(
        instance_type=ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE)
    )],
    launch_template=launch_template,
    vpc=vpc,
    vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC)
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • game_server_group_name (str) – (experimental) A developer-defined identifier for the game server group. The name is unique for each Region in each AWS account.

  • instance_definitions (Sequence[Union[InstanceDefinition, Dict[str, Any]]]) – (experimental) The set of Amazon EC2 instance types that GameLift FleetIQ can use when balancing and automatically scaling instances in the corresponding Auto Scaling group.

  • launch_template (ILaunchTemplate) – (experimental) The Amazon EC2 launch template that contains configuration settings and game server code to be deployed to all instances in the game server group. After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. NOTE: If you specify network interfaces in your launch template, you must explicitly set the property AssociatePublicIpAddress to true. If no network interface is specified in the launch template, GameLift FleetIQ uses your account’s default VPC.

  • vpc (IVpc) – (experimental) The VPC network to place the game server group in. By default, all GameLift FleetIQ-supported Availability Zones are used. You can use this parameter to specify VPCs that you’ve set up. This property cannot be updated after the game server group is created, and the corresponding Auto Scaling group will always use the property value that is set with this request, even if the Auto Scaling group is updated directly.

  • auto_scaling_policy (Union[AutoScalingPolicy, Dict[str, Any], None]) – (experimental) 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. After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. Default: no autoscaling policy settled

  • balancing_strategy (Optional[BalancingStrategy]) – (experimental) Indicates how GameLift FleetIQ balances the use of Spot Instances and On-Demand Instances in the game server group. Default: SPOT_PREFERRED

  • delete_option (Optional[DeleteOption]) – (experimental) The type of delete to perform. To delete a game server group, specify the DeleteOption Default: SAFE_DELETE

  • max_size (Union[int, float, None]) – (experimental) The maximum number of instances allowed in the Amazon EC2 Auto Scaling group. During automatic scaling events, GameLift FleetIQ and EC2 do not scale up the group above this maximum. After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. Default: the default is 1

  • min_size (Union[int, float, None]) – (experimental) The minimum number of instances allowed in the Amazon EC2 Auto Scaling group. During automatic scaling events, GameLift FleetIQ and Amazon EC2 do not scale down the group below this minimum. In production, this value should be set to at least 1. After the Auto Scaling group is created, update this value directly in the Auto Scaling group using the AWS console or APIs. Default: the default is 0

  • protect_game_server (Optional[bool]) – (experimental) 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 except in the event of a forced game server group deletion. An exception to this is with Spot Instances, which can be terminated by AWS regardless of protection status. Default: game servers running might be terminated during a scale-down event

  • role (Optional[IRole]) – (experimental) The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. Default: - a role will be created with default trust to Gamelift and Autoscaling service principal with a default policy GameLiftGameServerGroupPolicy attached.

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – (experimental) Game server group subnet selection. Default: all GameLift FleetIQ-supported Availability Zones are used.

Stability:

experimental

Methods

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

grant(grantee, *actions)

(experimental) Grant the grantee identity permissions to perform actions.

Parameters:
Stability:

experimental

Return type:

Grant

metric(metric_name, *, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

(experimental) Return the given named metric for this fleet.

Parameters:
  • metric_name (str) –

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Stability:

experimental

Return type:

Metric

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

auto_scaling_group_arn

(experimental) The ARN of the generated AutoScaling group.

Stability:

experimental

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

game_server_group_arn

(experimental) The ARN of the game server group.

Stability:

experimental

game_server_group_name

(experimental) The name of the game server group.

Stability:

experimental

grant_principal

(experimental) The principal this GameLift game server group is using.

Stability:

experimental

node

The tree node.

role

(experimental) The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups.

Stability:

experimental

stack

The stack in which this resource is defined.

vpc

(experimental) The VPC network to place the game server group in.

Stability:

experimental

vpc_subnets

(experimental) The game server group’s subnets.

Stability:

experimental

Static Methods

classmethod from_game_server_group_attributes(scope, id, *, auto_scaling_group_arn, game_server_group_arn=None, game_server_group_name=None, role=None)

(experimental) Import an existing game server group from its attributes.

Parameters:
  • scope (Construct) –

  • id (str) –

  • auto_scaling_group_arn (str) – (experimental) The ARN of the generated AutoScaling group. Default: the imported game server group does not have autoscaling group information

  • game_server_group_arn (Optional[str]) – (experimental) The ARN of the game server group. At least one of gameServerGroupArn and gameServerGroupName must be provided. Default: derived from gameServerGroupName.

  • game_server_group_name (Optional[str]) – (experimental) The name of the game server group. At least one of gameServerGroupArn and gameServerGroupName must be provided. Default: derived from gameServerGroupArn.

  • role (Optional[IRole]) – (experimental) The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. Default: the imported game server group cannot be granted access to other resources as an iam.IGrantable.

Stability:

experimental

Return type:

IGameServerGroup

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool