Experimental
@aws-cdk/aws-gamelift-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
BuildFleet L2 construct
A fleet contains Amazon Elastic Compute Cloud (Amazon EC2) instances that GameLift hosts.
A fleet uses the configuration and scaling logic that you define to run your game server build. You can use a fleet directly without a queue. You can also associate multiple fleets with a GameLift queue.
For example, you can use Spot Instance fleets configured with your preferred locations, along with a backup On-Demand Instance fleet with the same locations. Using multiple Spot Instance fleets of different instance types reduces the chance of needing On-Demand Instance placement.
Example
declare const build: gamelift.Build;
// Server processes can be delcared in a declarative way through the constructor
const fleet = new gamelift.BuildFleet(this, 'Game server fleet', {
fleetName: 'test-fleet',
content: build,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
runtimeConfiguration: {
serverProcesses: [{
launchPath: '/local/game/GameLiftExampleServer.x86_64',
parameters: '-logFile /local/game/logs/myserver1935.log -port 1935',
concurrentExecutions: 100,
}]
}
});
# build: gamelift.Build
# Server processes can be delcared in a declarative way through the constructor
fleet = gamelift.BuildFleet(self, "Game server fleet",
fleet_name="test-fleet",
content=build,
instance_type=ec2.InstanceType.of(ec2.InstanceClass.C4, ec2.InstanceSize.LARGE),
runtime_configuration=gamelift.RuntimeConfiguration(
server_processes=[gamelift.ServerProcess(
launch_path="/local/game/GameLiftExampleServer.x86_64",
parameters="-logFile /local/game/logs/myserver1935.log -port 1935",
concurrent_executions=100
)]
)
)
Build build;
// Server processes can be delcared in a declarative way through the constructor
BuildFleet fleet = BuildFleet.Builder.create(this, "Game server fleet")
.fleetName("test-fleet")
.content(build)
.instanceType(InstanceType.of(InstanceClass.C4, InstanceSize.LARGE))
.runtimeConfiguration(RuntimeConfiguration.builder()
.serverProcesses(List.of(ServerProcess.builder()
.launchPath("/local/game/GameLiftExampleServer.x86_64")
.parameters("-logFile /local/game/logs/myserver1935.log -port 1935")
.concurrentExecutions(100)
.build()))
.build())
.build();
// Install: dotnet add package Amazon.CDK.AWS.GameLift.Alpha
Build build;
// Server processes can be delcared in a declarative way through the constructor
var fleet = new BuildFleet(this, "Game server fleet", new BuildFleetProps {
FleetName = "test-fleet",
Content = build,
InstanceType = InstanceType.Of(InstanceClass.C4, InstanceSize.LARGE),
RuntimeConfiguration = new RuntimeConfiguration {
ServerProcesses = new [] { new ServerProcess {
LaunchPath = "/local/game/GameLiftExampleServer.x86_64",
Parameters = "-logFile /local/game/logs/myserver1935.log -port 1935",
ConcurrentExecutions = 100
} }
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdkgameliftalpha/v2
var build Build
// Server processes can be delcared in a declarative way through the constructor
fleet := gamelift.NewBuildFleet(this, jsii.String("Game server fleet"), &BuildFleetProps{
FleetName: jsii.String("test-fleet"),
Content: build,
InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_C4, ec2.InstanceSize_LARGE),
RuntimeConfiguration: &RuntimeConfiguration{
ServerProcesses: []ServerProcess{
&ServerProcess{
LaunchPath: jsii.String("/local/game/GameLiftExampleServer.x86_64"),
Parameters: jsii.String("-logFile /local/game/logs/myserver1935.log -port 1935"),
ConcurrentExecutions: jsii.Number(100),
},
},
},
})
Initializer
new BuildFleet(scope: Construct, id: string, props: BuildFleetProps)
BuildFleet(scope: Construct, id: str, props: BuildFleetProps)
new BuildFleet(Construct scope, String id, BuildFleetProps props)
new BuildFleet(Construct scope, string id, BuildFleetProps props)
NewBuildFleet(Scope Construct, Id *string, Props BuildFleetProps)
Construct Props
The build must have been successfully uploaded to Amazon GameLift and be in a READY status.
This fleet setting cannot be changed once the fleet is created.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#Default: no description is provided
desiredCapacityoptionalnumberdesired_capacityoptionalint | floatdesiredCapacityoptionalNumberDesiredCapacityoptionaldoubleDesiredCapacityoptional*float64#Default: Default capacity is 0
When creating a new fleet, GameLift automatically sets this value to "1" and initiates a single instance. Once the fleet is active, update this value to trigger GameLift to add or remove instances from the fleet.
Fleet names do not need to be unique.
ingressRulesoptionalIngressRule[]ingress_rulesoptionaltyping.List[IngressRule]ingressRulesoptionalList<IngressRule>IngressRulesoptionalIngressRule[]IngressRulesoptional*[]IngressRule#Default: no inbound traffic allowed
This property must be set before players can connect to game sessions.
instanceTypeInstanceTypeinstance_typeInstanceTypeinstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTyperequired#Instance type determines the computing resources that will be used to host your game servers, including CPU, memory, storage, and networking capacity.
locationsoptionalLocation[]locationsoptionaltyping.List[Location]locationsoptionalList<Location>LocationsoptionalLocation[]Locationsoptional*[]Location#Default: Create a fleet with instances in the home region only
notes
This parameter can only be used when creating fleets in AWS Regions that support multiple locations. You can add any GameLift-supported AWS Region as a remote location, in the form of an AWS Region code such as us-west-2. To create a fleet with instances in the home region only, omit this parameter.
maxSizeoptionalnumbermax_sizeoptionalint | floatmaxSizeoptionalNumberMaxSizeoptionaldoubleMaxSizeoptional*float64= 1#metricGroupoptionalstringmetric_groupoptionalstrmetricGroupoptionalStringMetricGroupoptionalstringMetricGroupoptional*string#Default: Fleet metrics are aggregated with other fleets in the default metric group
A metric group is used to aggregate the metrics for multiple fleets. You can specify an existing metric group name or set a new name to create a new metric group. A fleet can be included in only one metric group at a time.
minSizeoptionalnumbermin_sizeoptionalint | floatminSizeoptionalNumberMinSizeoptionaldoubleMinSizeoptional*float64= 0#Default: no vpc peering
notes
Use Amazon Virtual Private Cloud (VPC) peering connections to enable your game servers to communicate directly and privately with your other AWS resources, such as a web service or a repository. You can establish VPC peering with any resources that run on AWS and are managed by an AWS account that you have access to. The VPC must be in the same Region as your fleet.
Warning: Be sure to create a VPC Peering authorization through Gamelift Service API.
protectNewGameSessionoptionalbooleanprotect_new_game_sessionoptionalboolprotectNewGameSessionoptionalBooleanProtectNewGameSessionoptionalboolProtectNewGameSessionoptional*bool#Default: true - Game sessions in ACTIVE status cannot be terminated during a scale-down event.
By default, new game sessions are protected and cannot be terminated during a scale-down event.
resourceCreationLimitPolicyoptionalResourceCreationLimitPolicyresource_creation_limit_policyoptionalResourceCreationLimitPolicyresourceCreationLimitPolicyoptionalResourceCreationLimitPolicyResourceCreationLimitPolicyoptionalResourceCreationLimitPolicyResourceCreationLimitPolicyoptionalResourceCreationLimitPolicy#Default: No resource creation limit policy
Default: a role will be created with default trust to Gamelift service principal.
notes
With a role set, any application that runs on an instance in this fleet can assume the role, including install scripts, server processes, and daemons (background processes). If providing a custom role, it needs to trust the GameLift service principal (gamelift.amazonaws.com). No permission is required by default.
This property cannot be changed after the fleet is created.
runtimeConfigurationRuntimeConfigurationruntime_configurationRuntimeConfigurationruntimeConfigurationRuntimeConfigurationRuntimeConfigurationRuntimeConfigurationRuntimeConfigurationRuntimeConfigurationrequired#notes
Server processes run either an executable in a custom game build or a Realtime Servers script. GameLift launches the configured processes, manages their life cycle, and replaces them as needed. Each instance checks regularly for an updated runtime configuration.
A GameLift instance is limited to 50 processes running concurrently. To calculate the total number of processes in a runtime configuration, add the values of the ConcurrentExecutions parameter for each ServerProcess.
useCertificateoptionalbooleanuse_certificateoptionalbooluseCertificateoptionalBooleanUseCertificateoptionalboolUseCertificateoptional*bool#Default: TLS/SSL certificate are generated for the fleet
notes
GameLift uses the certificates to encrypt traffic between game clients and the game servers running on GameLift.
You can't change this property after you create the fleet.
Additionnal info: AWS Certificate Manager (ACM) certificates expire after 13 months. Certificate expiration can cause fleets to fail, preventing players from connecting to instances in the fleet. We recommend you replace fleets before 13 months, consider using fleet aliases for a smooth transition.
useSpotoptionalbooleanuse_spotoptionalbooluseSpotoptionalBooleanUseSpotoptionalboolUseSpotoptional*bool#Default: Gamelift fleet use on demand capacity
This property cannot be changed after the fleet is created.
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#resourceArnForDestinationstringresource_arn_for_destinationstrresourceArnForDestinationStringResourceArnForDestinationstringResourceArnForDestination*string#Methods
addAlias(aliasName: string, options?: AliasOptions): Aliasdef add_alias(self, alias_name: str, options: typing.Optional[AliasOptions] = None) -> Aliaspublic Alias addAlias(String aliasName, AliasOptions options)public Alias AddAlias(string aliasName, AliasOptions? options = null)func AddAlias(AliasName *string, Options AliasOptions) Alias#declare const fleet: gamelift.FleetBase;
fleet.addAlias('Live');
// Is equivalent to
new gamelift.Alias(this, 'AliasLive', {
aliasName: 'Live',
fleet: fleet,
});
2 parameters
Parameters
aliasNamealias_namealiasNamealiasNameAliasName— The name of the alias.optionsoptionsoptionsoptionsOptions— Alias options.
addIngressRule(source: IPeer, port: Port): voiddef add_ingress_rule(self, source: IPeer, port: Port) -> Nonepublic void addIngressRule(IPeer source, Port port)public void AddIngressRule(IPeer source, Port port)func AddIngressRule(Source IPeer, Port Port)#2 parameters
Parameters
sourcesourcesourcesourceSource— A range of allowed IP addresses.portportportportPort— The port range used for ingress traffic.
addInternalLocation(location: Location): voiddef add_internal_location(self, location: Location) -> Nonepublic void addInternalLocation(Location location)public void AddInternalLocation(Location location)func AddInternalLocation(Location Location)#1 parameter
Parameters
locationlocationlocationlocationLocation— The location to add.
addLocation(region: string, desiredCapacity?: number, minSize?: number, maxSize?: number): voiddef add_location(self, region: str, desired_capacity: typing.Optional[int | float] = None, min_size: typing.Optional[int | float] = None, max_size: typing.Optional[int | float] = None) -> Nonepublic void addLocation(String region, Number desiredCapacity, Number minSize, Number maxSize)public void AddLocation(string region, double? desiredCapacity = null, double? minSize = null, double? maxSize = null)func AddLocation(Region *string, DesiredCapacity *float64, MinSize *float64, MaxSize *float64)#1 parameter
Parameters
regionregionregionregionRegion— The AWS region to add.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromBuildFleetArn(scope: Construct, id: string, buildFleetArn: string): IBuildFleet@staticmethod def from_build_fleet_arn(scope: Construct, id: str, build_fleet_arn: str) -> IBuildFleetpublic static IBuildFleet fromBuildFleetArn(Construct scope, String id, String buildFleetArn)public static IBuildFleet FromBuildFleetArn(Construct scope, string id, string buildFleetArn)func FromBuildFleetArn(Scope Construct, Id *string, BuildFleetArn *string) IBuildFleetstatic#fromBuildFleetId(scope: Construct, id: string, buildFleetId: string): IBuildFleet@staticmethod def from_build_fleet_id(scope: Construct, id: str, build_fleet_id: str) -> IBuildFleetpublic static IBuildFleet fromBuildFleetId(Construct scope, String id, String buildFleetId)public static IBuildFleet FromBuildFleetId(Construct scope, string id, string buildFleetId)func FromBuildFleetId(Scope Construct, Id *string, BuildFleetId *string) IBuildFleetstatic#fromFleetAttributes(scope: Construct, id: string, attrs: FleetAttributes): IFleet@staticmethod def from_fleet_attributes(scope: Construct, id: str, attrs: FleetAttributes) -> IFleetpublic static IFleet fromFleetAttributes(Construct scope, String id, FleetAttributes attrs)public static IFleet FromFleetAttributes(Construct scope, string id, FleetAttributes attrs)func FromFleetAttributes(Scope Construct, Id *string, Attrs FleetAttributes) IFleetstatic#grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
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
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#metricActiveInstances(props?: MetricOptions): Metricdef metric_active_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricActiveInstances(MetricOptions props)public Metric MetricActiveInstances(MetricOptions? props = null)func MetricActiveInstances(Props MetricOptions) Metric#The count includes idle instances and those that are hosting one or more game sessions. This metric measures current total instance capacity.
This metric can be used with automatic scaling.
metricDesiredInstances(props?: MetricOptions): Metricdef metric_desired_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricDesiredInstances(MetricOptions props)public Metric MetricDesiredInstances(MetricOptions? props = null)func MetricDesiredInstances(Props MetricOptions) Metric#With automatic scaling, this value is determined based on the scaling policies currently in force. Without automatic scaling, this value is set manually. This metric is not available when viewing data for fleet metric groups.
metricIdleInstances(props?: MetricOptions): Metricdef metric_idle_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricIdleInstances(MetricOptions props)public Metric MetricIdleInstances(MetricOptions? props = null)func MetricIdleInstances(Props MetricOptions) Metric#This metric measures capacity that is available but unused. This metric can be used with automatic scaling.
metricInstanceInterruptions(props?: MetricOptions): Metricdef metric_instance_interruptions(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricInstanceInterruptions(MetricOptions props)public Metric MetricInstanceInterruptions(MetricOptions? props = null)func MetricInstanceInterruptions(Props MetricOptions) Metric#metricMaxInstances(props?: MetricOptions): Metricdef metric_max_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricMaxInstances(MetricOptions props)public Metric MetricMaxInstances(MetricOptions? props = null)func MetricMaxInstances(Props MetricOptions) Metric#A fleet's instance maximum determines the capacity ceiling during manual or automatic scaling up. This metric is not available when viewing data for fleet metric groups.
metricMinInstances(props?: MetricOptions): Metricdef metric_min_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricMinInstances(MetricOptions props)public Metric MetricMinInstances(MetricOptions? props = null)func MetricMinInstances(Props MetricOptions) Metric#A fleet's instance minimum determines the capacity floor during manual or automatic scaling down. This metric is not available when viewing data for fleet metric groups.
metricPercentIdleInstances(props?: MetricOptions): Metricdef metric_percent_idle_instances(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPercentIdleInstances(MetricOptions props)public Metric MetricPercentIdleInstances(MetricOptions? props = null)func MetricPercentIdleInstances(Props MetricOptions) Metric#This metric can be used for automatic scaling.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.