class GameServerGroup (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.GameLift.Alpha.GameServerGroup |
![]() | github.com/aws/aws-cdk-go/awscdkgameliftalpha/v2#GameServerGroup |
![]() | software.amazon.awscdk.services.gamelift.alpha.GameServerGroup |
![]() | aws_cdk.aws_gamelift_alpha.GameServerGroup |
![]() | @aws-cdk/aws-gamelift-alpha ยป GameServerGroup |
Implements
IConstruct
, IDependable
, IResource
, IGame
, IGrantable
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 also: https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html
Example
declare const launchTemplate: ec2.ILaunchTemplate;
declare const vpc: ec2.IVpc;
new gamelift.GameServerGroup(this, 'GameServerGroup', {
gameServerGroupName: 'sample-gameservergroup-name',
instanceDefinitions: [{
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.LARGE),
},
{
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
}],
launchTemplate: launchTemplate,
vpc: vpc,
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }
});
Initializer
new GameServerGroup(scope: Construct, id: string, props: GameServerGroupProps)
Parameters
- scope
Construct
- id
string
- props
Game
Server Group Props
Construct Props
Name | Type | Description |
---|---|---|
game | string | A developer-defined identifier for the game server group. |
instance | Instance [] | 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 | ILaunch | The Amazon EC2 launch template that contains configuration settings and game server code to be deployed to all instances in the game server group. |
vpc | IVpc | The VPC network to place the game server group in. |
auto | Auto | Configuration settings to define a scaling policy for the Auto Scaling group that is optimized for game hosting. |
balancing | Balancing | Indicates how GameLift FleetIQ balances the use of Spot Instances and On-Demand Instances in the game server group. |
delete | Delete | The type of delete to perform. |
max | number | The maximum number of instances allowed in the Amazon EC2 Auto Scaling group. |
min | number | The minimum number of instances allowed in the Amazon EC2 Auto Scaling group. |
protect | boolean | A flag that indicates whether instances in the game server group are protected from early termination. |
role? | IRole | The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. |
vpc | Subnet | Game server group subnet selection. |
gameServerGroupName
Type:
string
A developer-defined identifier for the game server group.
The name is unique for each Region in each AWS account.
instanceDefinitions
Type:
Instance
[]
The set of Amazon EC2 instance types that GameLift FleetIQ can use when balancing and automatically scaling instances in the corresponding Auto Scaling group.
launchTemplate
Type:
ILaunch
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
Type:
IVpc
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.
autoScalingPolicy?
Type:
Auto
(optional, default: no autoscaling policy settled)
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.
balancingStrategy?
Type:
Balancing
(optional, default: SPOT_PREFERRED)
Indicates how GameLift FleetIQ balances the use of Spot Instances and On-Demand Instances in the game server group.
deleteOption?
Type:
Delete
(optional, default: SAFE_DELETE)
The type of delete to perform.
To delete a game server group, specify the DeleteOption
maxSize?
Type:
number
(optional, default: the default is 1)
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.
minSize?
Type:
number
(optional, default: the default is 0)
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.
protectGameServer?
Type:
boolean
(optional, default: game servers running might be terminated during a scale-down event)
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.
role?
Type:
IRole
(optional, default: a role will be created with default trust to Gamelift and Autoscaling service principal with a default policy GameLiftGameServerGroupPolicy
attached.)
The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups.
vpcSubnets?
Type:
Subnet
(optional, default: all GameLift FleetIQ-supported Availability Zones are used.)
Game server group subnet selection.
Properties
Name | Type | Description |
---|---|---|
auto | string | The ARN of the generated AutoScaling group. |
env | Resource | The environment this resource belongs to. |
game | string | The ARN of the game server group. |
game | string | The name of the game server group. |
grant | IPrincipal | The principal this GameLift game server group is using. |
node | Node | The tree node. |
role | IRole | The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups. |
stack | Stack | The stack in which this resource is defined. |
vpc | IVpc | The VPC network to place the game server group in. |
vpc | Subnet | The game server group's subnets. |
autoScalingGroupArn
Type:
string
The ARN of the generated AutoScaling group.
env
Type:
Resource
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.
gameServerGroupArn
Type:
string
The ARN of the game server group.
gameServerGroupName
Type:
string
The name of the game server group.
grantPrincipal
Type:
IPrincipal
The principal this GameLift game server group is using.
node
Type:
Node
The tree node.
role
Type:
IRole
The IAM role that allows Amazon GameLift to access your Amazon EC2 Auto Scaling groups.
stack
Type:
Stack
The stack in which this resource is defined.
vpc
Type:
IVpc
The VPC network to place the game server group in.
vpcSubnets?
Type:
Subnet
(optional)
The game server group's subnets.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
grant(grantee, ...actions) | Grant the grantee identity permissions to perform actions . |
metric(metricName, props?) | Return the given named metric for this fleet. |
to | Returns a string representation of this construct. |
protected parse | |
protected parse | |
protected parse | |
static from | Import an existing game server group from its attributes. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string
Returns
Grant the grantee
identity permissions to perform actions
.
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for this fleet.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected parseAutoScalingPolicy(props)
protected parseAutoScalingPolicy(props: GameServerGroupProps): AutoScalingPolicyProperty
Parameters
- props
Game
Server Group Props
Returns
protected parseInstanceDefinitions(props)
protected parseInstanceDefinitions(props: GameServerGroupProps): InstanceDefinitionProperty[]
Parameters
- props
Game
Server Group Props
Returns
protected parseLaunchTemplate(props)
protected parseLaunchTemplate(props: GameServerGroupProps): LaunchTemplateProperty
Parameters
- props
Game
Server Group Props
Returns
static fromGameServerGroupAttributes(scope, id, attrs)
public static fromGameServerGroupAttributes(scope: Construct, id: string, attrs: GameServerGroupAttributes): IGameServerGroup
Parameters
- scope
Construct
- id
string
- attrs
Game
Server Group Attributes
Returns
Import an existing game server group from its attributes.