createFleet method
- required String name,
- AnywhereConfiguration? anywhereConfiguration,
- String? buildId,
- CertificateConfiguration? certificateConfiguration,
- ComputeType? computeType,
- String? description,
- List<
IpPermission> ? eC2InboundPermissions, - EC2InstanceType? eC2InstanceType,
- FleetType? fleetType,
- String? instanceRoleArn,
- InstanceRoleCredentialsProvider? instanceRoleCredentialsProvider,
- List<
LocationConfiguration> ? locations, - List<
String> ? logPaths, - List<
String> ? metricGroups, - ProtectionPolicy? newGameSessionProtectionPolicy,
- String? peerVpcAwsAccountId,
- String? peerVpcId,
- PlayerGatewayConfiguration? playerGatewayConfiguration,
- PlayerGatewayMode? playerGatewayMode,
- ResourceCreationLimitPolicy? resourceCreationLimitPolicy,
- RuntimeConfiguration? runtimeConfiguration,
- String? scriptId,
- String? serverLaunchParameters,
- String? serverLaunchPath,
- List<
Tag> ? tags,
This API works with the following fleet types: EC2, Anywhere, Container
Creates a fleet of compute resources to host your game servers. Use this operation to set up a fleet for the following compute types:
Managed EC2 fleet
An EC2 fleet is a set of Amazon Elastic Compute Cloud (Amazon EC2)
instances. Your game server build is deployed to each fleet instance.
Amazon GameLift Servers manages the fleet's instances and controls the
lifecycle of game server processes, which host game sessions for players.
EC2 fleets can have instances in multiple locations. Each instance in the
fleet is designated a Compute.
To create an EC2 fleet, provide these required parameters:
-
Either
BuildIdorScriptId -
ComputeTypeset toEC2(the default value) -
EC2InboundPermissions -
EC2InstanceType -
FleetType -
Name -
RuntimeConfigurationwith at least oneServerProcessesconfiguration
NEW status while Amazon GameLift Servers initiates the fleet
creation workflow. To debug your fleet, fetch logs, view performance
metrics or other actions on the fleet, create a development fleet with
port 22/3389 open. As a best practice, we recommend opening ports for
remote access only when you need them and closing them when you're
finished.
When the fleet status is ACTIVE, you can adjust capacity settings and turn autoscaling on/off for each location. Anywhere fleet
An Anywhere fleet represents compute resources that are not owned or managed by Amazon GameLift Servers. You might create an Anywhere fleet with your local machine for testing, or use one to host game servers with on-premises hardware or other game hosting solutions.
To create an Anywhere fleet, provide these required parameters:
-
ComputeTypeset toANYWHERE -
Locationsspecifying a custom location -
Name
ACTIVE status. You can register computes with a fleet in
ACTIVE status.
Learn more
May throw ConflictException.
May throw InternalServiceException.
May throw InvalidRequestException.
May throw LimitExceededException.
May throw NotFoundException.
May throw NotReadyException.
May throw TaggingFailedException.
May throw UnauthorizedException.
May throw UnsupportedRegionException.
Parameter name :
A descriptive label that is associated with a fleet. Fleet names do not
need to be unique.
Parameter anywhereConfiguration :
Amazon GameLift Servers Anywhere configuration options.
Parameter buildId :
The unique identifier for a custom game server build to be deployed to a
fleet with compute type EC2. You can use either the build ID
or ARN. The build must be uploaded to Amazon GameLift Servers and in
READY status. This fleet property can't be changed after the
fleet is created.
Parameter certificateConfiguration :
Prompts Amazon GameLift Servers to generate a TLS/SSL certificate for the
fleet. Amazon GameLift Servers uses the certificates to encrypt traffic
between game clients and the game servers running on Amazon GameLift
Servers. By default, the CertificateConfiguration is
DISABLED. You can't change this property after you create the
fleet.
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.
Parameter computeType :
The type of compute resource used to host your game servers.
-
EC2– The game server build is deployed to Amazon EC2 instances for cloud hosting. This is the default setting. -
ANYWHERE– Game servers and supporting software are deployed to compute resources that you provide and manage. With this compute type, you can also set theAnywhereConfigurationparameter.
Parameter description :
A description for the fleet.
Parameter eC2InboundPermissions :
The IP address ranges and port settings that allow inbound traffic to
access game server processes and other processes on this fleet. Set this
parameter for managed EC2 fleets. You can leave this parameter empty when
creating the fleet, but you must call https://docs.aws.amazon.com/gamelift/latest/apireference/API_UpdateFleetPortSettings
to set it before players can connect to game sessions. As a best practice,
we recommend opening ports for remote access only when you need them and
closing them when you're finished. For Amazon GameLift Servers Realtime
fleets, Amazon GameLift Servers automatically sets TCP and UDP ranges.
Parameter eC2InstanceType :
The Amazon GameLift Servers-supported Amazon EC2 instance type to use with
managed EC2 fleets. Instance type determines the computing resources that
will be used to host your game servers, including CPU, memory, storage,
and networking capacity. See Amazon Elastic Compute
Cloud Instance Types for detailed descriptions of Amazon EC2 instance
types.
Parameter fleetType :
Indicates whether to use On-Demand or Spot instances for this fleet. By
default, this property is set to ON_DEMAND. Learn more about
when to use
On-Demand versus Spot Instances. This fleet property can't be changed
after the fleet is created.
Parameter instanceRoleArn :
A unique identifier for an IAM role that manages access to your Amazon Web
Services services. With an instance role ARN set, any application that
runs on an instance in this fleet can assume the role, including install
scripts, server processes, and daemons (background processes). Create a
role or look up a role's ARN by using the IAM dashboard in the Amazon
Web Services Management Console. Learn more about using on-box credentials
for your game servers at
Access external resources from a game server. This fleet property
can't be changed after the fleet is created.
Parameter instanceRoleCredentialsProvider :
Prompts Amazon GameLift Servers to generate a shared credentials file for
the IAM role that's defined in InstanceRoleArn. The shared
credentials file is stored on each fleet instance and refreshed as needed.
Use shared credentials for applications that are deployed along with the
game server executable, if the game server is integrated with server SDK
version 5.x. For more information about using shared credentials, see
Communicate with other Amazon Web Services resources from your fleets.
Parameter locations :
A set of remote locations to deploy additional instances to and manage as
a multi-location fleet. Use this parameter when creating a fleet in Amazon
Web Services Regions that support multiple locations. You can add any
Amazon Web Services Region or Local Zone that's supported by Amazon
GameLift Servers. Provide a list of one or more Amazon Web Services Region
codes, such as us-west-2, or Local Zone names. When using
this parameter, Amazon GameLift Servers requires you to include your home
location in the request. For a list of supported Regions and Local Zones,
see
Amazon GameLift Servers service locations for managed hosting.
Parameter logPaths :
This parameter is no longer used. To specify where Amazon GameLift
Servers should store log files once a server process shuts down, use the
Amazon GameLift Servers server API ProcessReady() and specify
one or more directory paths in logParameters. For more
information, see Initialize
the server process in the Amazon GameLift Servers Developer
Guide.
Parameter metricGroups :
The name of an Amazon Web Services CloudWatch metric group to add this
fleet to. 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.
Parameter newGameSessionProtectionPolicy :
The status of termination protection for active game sessions on the
fleet. By default, this property is set to NoProtection. You
can also set game session protection for an individual game session by
calling UpdateGameSession.
- NoProtection - Game sessions can be terminated during active gameplay as a result of a scale-down event.
-
FullProtection - Game sessions in
ACTIVEstatus cannot be terminated during a scale-down event.
Parameter peerVpcAwsAccountId :
Used when peering your Amazon GameLift Servers fleet with a VPC, the
unique identifier for the Amazon Web Services account that owns the VPC.
You can find your account ID in the Amazon Web Services Management Console
under account settings.
Parameter peerVpcId :
A unique identifier for a VPC with resources to be accessed by your Amazon
GameLift Servers fleet. The VPC must be in the same Region as your fleet.
To look up a VPC ID, use the VPC Dashboard in the Amazon
Web Services Management Console. Learn more about VPC peering in VPC
Peering with Amazon GameLift Servers Fleets.
Parameter playerGatewayConfiguration :
Configuration settings for player gateway. Use this to specify advanced
options for how player gateway handles connections.
Parameter playerGatewayMode :
Configures player gateway for your fleet. Player gateway provides benefits
such as DDoS protection by rate limiting and validating traffic before it
reaches game servers, hiding game server IP addresses from players, and
providing updated endpoints when relay endpoints become unhealthy. Note,
player gateway is only available for fleets using server SDK 5.x or later
game server builds.
How it works: When enabled, game clients connect to relay endpoints instead of to your game servers. Player gateway validates player gateway tokens and routes traffic to the appropriate game server. Your game backend calls GetPlayerConnectionDetails to retrieve relay endpoints and player gateway tokens for your game clients. To learn more about this topic, see DDoS protection with Amazon GameLift Servers player gateway.
Possible values include:
-
DISABLED(default) -- Game clients connect to the game server endpoint. Use this when you do not intend to integrate your game with player gateway. -
ENABLED-- Player gateway is available in fleet locations where it is supported. Your game backend can call GetPlayerConnectionDetails to obtain a player gateway token and endpoints for game clients. -
REQUIRED-- Player gateway is available in fleet locations where it is supported, and the fleet can only use locations that support this feature. Attempting to add a remote location to your fleet which does not support player gateway will result in anInvalidRequestException.
Parameter resourceCreationLimitPolicy :
A policy that limits the number of game sessions that an individual player
can create on instances in this fleet within a specified span of time.
Parameter runtimeConfiguration :
Instructions for how to launch and run server processes on the fleet. Set
runtime configuration for managed EC2 fleets. For an Anywhere fleets, set
this parameter only if the fleet is running the Amazon GameLift Servers
Agent. The runtime configuration defines one or more server process
configurations. Each server process identifies a game executable or
Realtime script file and the number of processes to run concurrently.
Parameter scriptId :
The unique identifier for a Realtime configuration script to be deployed
to a fleet with compute type EC2. You can use either the
script ID or ARN. Scripts must be uploaded to Amazon GameLift Servers
prior to creating the fleet. This fleet property can't be changed after
the fleet is created.
Parameter serverLaunchParameters :
This parameter is no longer used. Specify server launch parameters
using the RuntimeConfiguration parameter. Requests that use
this parameter instead continue to be valid.
Parameter serverLaunchPath :
This parameter is no longer used. Specify a server launch path
using the RuntimeConfiguration parameter. Requests that use
this parameter instead continue to be valid.
Parameter tags :
A list of labels to assign to the new fleet resource. Tags are
developer-defined key-value pairs. Tagging Amazon Web Services resources
are useful for resource management, access management and cost allocation.
For more information, see
Tagging Amazon Web Services Resources in the Amazon Web Services
General Reference.
Implementation
Future<CreateFleetOutput> createFleet({
required String name,
AnywhereConfiguration? anywhereConfiguration,
String? buildId,
CertificateConfiguration? certificateConfiguration,
ComputeType? computeType,
String? description,
List<IpPermission>? eC2InboundPermissions,
EC2InstanceType? eC2InstanceType,
FleetType? fleetType,
String? instanceRoleArn,
InstanceRoleCredentialsProvider? instanceRoleCredentialsProvider,
List<LocationConfiguration>? locations,
List<String>? logPaths,
List<String>? metricGroups,
ProtectionPolicy? newGameSessionProtectionPolicy,
String? peerVpcAwsAccountId,
String? peerVpcId,
PlayerGatewayConfiguration? playerGatewayConfiguration,
PlayerGatewayMode? playerGatewayMode,
ResourceCreationLimitPolicy? resourceCreationLimitPolicy,
RuntimeConfiguration? runtimeConfiguration,
String? scriptId,
String? serverLaunchParameters,
String? serverLaunchPath,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'GameLift.CreateFleet'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Name': name,
if (anywhereConfiguration != null)
'AnywhereConfiguration': anywhereConfiguration,
if (buildId != null) 'BuildId': buildId,
if (certificateConfiguration != null)
'CertificateConfiguration': certificateConfiguration,
if (computeType != null) 'ComputeType': computeType.value,
if (description != null) 'Description': description,
if (eC2InboundPermissions != null)
'EC2InboundPermissions': eC2InboundPermissions,
if (eC2InstanceType != null) 'EC2InstanceType': eC2InstanceType.value,
if (fleetType != null) 'FleetType': fleetType.value,
if (instanceRoleArn != null) 'InstanceRoleArn': instanceRoleArn,
if (instanceRoleCredentialsProvider != null)
'InstanceRoleCredentialsProvider':
instanceRoleCredentialsProvider.value,
if (locations != null) 'Locations': locations,
if (logPaths != null) 'LogPaths': logPaths,
if (metricGroups != null) 'MetricGroups': metricGroups,
if (newGameSessionProtectionPolicy != null)
'NewGameSessionProtectionPolicy':
newGameSessionProtectionPolicy.value,
if (peerVpcAwsAccountId != null)
'PeerVpcAwsAccountId': peerVpcAwsAccountId,
if (peerVpcId != null) 'PeerVpcId': peerVpcId,
if (playerGatewayConfiguration != null)
'PlayerGatewayConfiguration': playerGatewayConfiguration,
if (playerGatewayMode != null)
'PlayerGatewayMode': playerGatewayMode.value,
if (resourceCreationLimitPolicy != null)
'ResourceCreationLimitPolicy': resourceCreationLimitPolicy,
if (runtimeConfiguration != null)
'RuntimeConfiguration': runtimeConfiguration,
if (scriptId != null) 'ScriptId': scriptId,
if (serverLaunchParameters != null)
'ServerLaunchParameters': serverLaunchParameters,
if (serverLaunchPath != null) 'ServerLaunchPath': serverLaunchPath,
if (tags != null) 'Tags': tags,
},
);
return CreateFleetOutput.fromJson(jsonResponse.body);
}