

# Create an Amazon GameLift Servers managed EC2 fleet
<a name="fleets-creating"></a>

This topic describes how to create an Amazon GameLift Servers managed EC2 fleet. Managed fleets use Amazon Elastic Compute Cloud (Amazon EC2) compute instances that are optimized for multiplayer game hosting. You can create managed fleets that deploy computes to globally to Amazon Web Services Regions and Local Zones supported by Amazon GameLift Servers.

When you create a new managed EC2 fleet resource, you immediately initiate the first phase of fleet creation. Managed fleet creation passes through several phases as Amazon GameLift Servers deploys an EC2 instance, installs a runtime environment and your game server build on the instance, and begins launching game servers. Depending on the runtime environment your game server build requires, Amazon GameLift Servers deploys the latest version of the Amazon Machine Image (AMI) at the time of fleet creation (and all future instances in the fleet will use the same version).You can monitor a fleet's status in the console or using the Amazon Command Line Interface (Amazon CLI). When a fleet is ready to host game sessions, the status changes to `ACTIVE`. For more information about managed fleet creation, see these topics: 

**Note**  
As a best practice, we recommend replacing your fleets every 30 days to maintain a secure and up-to-date runtime environment for your hosted game servers. This requires creating a new fleet and migrating player traffic to it. For more guidance, see [Security best practices for Amazon GameLift Servers](security-best-practices.md).

**To create a managed EC2 fleet**

Use either the Amazon GameLift Servers console or the Amazon Command Line Interface (Amazon CLI) to create a managed EC2 fleet. 

------
#### [ Console ]

**To create a managed EC2 fleet**

1. In the [Amazon GameLift Servers console](https://console.amazonaws.cn/gamelift/), in the navigation pane, choose **Fleets**.

1. On the **Fleets** page, choose **Create fleet**.

1. Choose **Managed EC2**.

1. On the **Fleet details** page do the following:

   1. For **Name**, enter a fleet name. We recommend including the fleet type (Spot or On-demand) in your fleet names. This makes it much easier to identify fleet types when viewing a list of fleets.

   1. For **Description**, provide a short description of the fleet.

   1. For **Binary type**, select **Build** to identify the type game server to deploy to this fleet.

   1. Select a **Build** from the dropdown list of previously uploaded game server builds.

1. (Optional) Under **Additional details** for the following:

   1. For **Instance role**, specify an IAM role that authorizes applications in your game build to access other Amazon resources in your account. For more information, see [Connect your Amazon GameLift Servers hosted game server to other Amazon resources](gamelift-sdk-server-resources.md). To create a fleet with an instance role, your account must have the IAM `PassRole` permission. For more information, see [IAM permission examples for Amazon GameLift Servers](gamelift-iam-policy-examples.md).

      You can't update these settings after fleet creation.

   1. For **Metric group**, Enter the name of a new or existing fleet metric group. You can aggregate the metrics for multiple fleets by adding them to the same metric group.

      You can't update the metric group after fleet creation.

1. Choose **Next**.

1. On the **Select locations** page, select one or more additional remote locations to deploy instances to. The home Region is automatically selected based on the Region you are accessing the console from. If you select additional locations, fleet instances are also deployed in these locations. 
**Important**  
To use Regions that aren't enabled by default, enable them in your Amazon Web Services account.  
Fleets with Regions that aren't enabled that you created before February 28, 2022 are not affected by this requirement.
To create new multi-location fleets or to update existing multi-location fleets, first enable any Regions or Local Zones that you choose to use.
For more information about Regions that aren't enabled by default and how to enable them, see [Managing Amazon Web Services Regions](https://docs.amazonaws.cn/general/latest/gr/rande-manage.html) in the *Amazon Web Services General Reference*. See [Getting started with Local Zones](https://docs.amazonaws.cn/local-zones/latest/ug/getting-started.html) in the *Amazon Local Zones User Guide*.

1. Choose **Next**.

1. On the **Define instance details page**, choose 

   1. **On-demand** or **Spot** instances for this fleet. For more information about fleet types, see [On-Demand Instances versus Spot Instances](gamelift-compute.md#gamelift-compute-spot). 

   1. From the **Filter architecture** menu choose **x64** or **Arm**. 
**Note**  
Graviton Arm instances require a server build for a Linux AMI. Server SDK 5.1.1 or newer is required for C\+\+ and C\#. Server SDK 5.0 or newer is required for Go. These instances do not provide out-of-the-box support for Mono installation on Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2). 
**Note**  
If you select an ARM architecture instance, make sure the build you selected runs on ARM architecture. Otherwise the fleet deployment will fail. 

       For information on Amazon EC2 Arm architectures, see [Amazon Graviton Processor](https://aws.amazon.com/ec2/graviton/) and [Amazon EC2 instance types](https://aws.amazon.com/ec2/instance-types/). 

   For information on the instance types supported by Amazon GameLift Servers, see the `EC2InstanceType` values under [CreateFleet() request parameters](https://docs.amazonaws.cn/gameliftservers/latest/apireference/API_CreateFleet.html#API_CreateFleet_RequestParameters). 

1. Select an Amazon EC2 **Instance type** from the list. For more information about choosing an instance type, see [Instance types](gamelift-compute.md#gamelift-compute-instance). After you create the fleet, you can't change the instance type.

1. Choose **Next**.

1. On the **Configure runtime** page, under **Runtime configuration** do the following:

   1. For **Launch path**, enter the path to the game executable in your build. On Windows instances, game servers are built to the path `C:\game`. On Linux instances, game servers are built to `/local/game`. Examples: **C:\\game\\MyGame\\server.exe** or **/local/game/MyGame/server.exe**.

   1. (Optional) For **Launch parameters**, enter information to pass to your game executable as a set of command line parameters. Example: **\+sv\_port 33435 \+start\_lobby**.

   1. For **Concurrent processes**, choose the number of server processes to run concurrently on each instance in the fleet. Review the Amazon GameLift Servers [limits](http://www.amazonaws.cn//ec2/faqs/#Is_Amazon_EC2_used_in_conjunction_with_Amazon_S3) on number of concurrent server processes. 

      Limits on concurrent server processes per instance apply to the total of concurrent processes for all configurations. If you configure the fleet to exceed the limit, the fleet can't activate.

1. Under **Game session activation**, provide limits for activating new game sessions on the instances in this fleet:

   1. For **Max concurrent game session activation**, enter the number of game sessions on an instance that activate at the same time. This limit is useful when launching multiple new game sessions may have an impact on the performance of other game sessions running on the instance.

   1. For **New activation timeout**, enter how long to wait for a session to activate. If the game session doesn't move to `ACTIVE` status before the timeout, Amazon GameLift Servers terminates the game session activation. 

1. (Optional) Under **EC2 port settings**, do the following:

   1. Choose **Add port setting** to define access permissions for inbound traffic connecting to the server process deployed on the fleet.

   1. For **Type**, choose **Custom TCP** or **Custom UDP**.

   1. For **Port range**, Enter a range of port numbers that allow inbound connections. A port range must use the format `nnnnn[-nnnnn]`, with values between 1026 and 60000. Example: **1500** or **1500-20000**. 

   1. For **IP address range**, Enter a range of IP addresses. Use CIDR notation. Example: **0.0.0.0/0** (This example allows access to anyone trying to connect.)

1. (Optional) Under **Game session resource settings** do the following:

   1. For **Game scaling protection policy**, Turn on or off scaling protection. Amazon GameLift Servers won't terminate instance with protection during a scale down event if they're hosting an active game session.

   1. For **Resource creation limit**, enter a maximum number of game sessions a player can create during the policy period.

1. Choose **Next**.

1. (Optional) Add tags to the build by entering **Key** and **Value** pairs. Choose **Next** to continue to fleet creation review.

1. Choose **Create**. Amazon GameLift Servers assigns an ID to the new fleet and begins the fleet activation process. You can track the new fleet's status on the **Fleets** page. 

You can update the fleet's metadata and configuration at any time, regardless of fleet status. For more information, see [Update an Amazon GameLift Servers fleet configuration](fleets-editing.md). You can update fleet capacity after the fleet has reached ACTIVE status. For more information, see [Scaling game hosting capacity with Amazon GameLift Servers](fleets-manage-capacity.md). You can also add or remove remote locations.

------
#### [ Amazon CLI ]

Use the [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/gamelift/create-fleet.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/gamelift/create-fleet.html) command to create a fleet of compute type `EC2`. Amazon GameLift Servers creates the fleet resource in your current default Amazon Web Services Region (or you can add a --region tag to specify a different Amazon Web Services Region).

**Create a minimal managed fleet**

The following example request creates a new fleet with the minimal settings that are required to deploy a fleet with running game servers that game clients can connect to. The new fleet has these characteristics: 
+ It specifies a game server build, which has been uploaded to Amazon GameLift Servers and in `READY` status.
+ Is uses c5.large On-Demand Instances with an operating system that matches the selected game build.
+ It sets the fleet's home Amazon Web Services Region to `us-west-2` and deploys instances to that Region only.
+ Based on the runtime configuration, each compute in the fleet runs one game server process, which means that each compute can host only one game session at a time. Game session activation timeout is set to the default value of 300 seconds, and there's no limit on the number of concurrent activations.
+ Players can connect to game servers using a single port setting of `33435`.
+ All other features are either turned off or use default settings.

```
aws gamelift create-fleet \
    --name MinimalFleet123 \
    --description "A basic test fleet" \
    --region us-west-2 \
    --ec2-instance-type c5.large \
    --fleet-type ON_DEMAND \
    --build-id build-1111aaaa-22bb-33cc-44dd-5555eeee66ff \
    --runtime-configuration "ServerProcesses=[{LaunchPath=C:\game\Bin64.dedicated\MultiplayerSampleProjectLauncher_Server.exe, ConcurrentExecutions=10}]" \
    --ec2-inbound-permissions "FromPort=33435,ToPort=33435,IpRange=0.0.0.0/0,Protocol=UDP"
```

**Create a fully configured managed fleet**

The following example request creates a production fleet with settings for all optional features. The new fleet has these characteristics: 
+ It specifies a game server build, which has been uploaded to Amazon GameLift Servers and in `READY` status.
+ It uses c5.large On-Demand Instances with the operating system that matches the selected game build. 
+ It sets the fleet's home Amazon Web Services Region to `us-west-2` and deploys instances to the home Region and one remote location `sa-east-1`. 
+ Based on the runtime configuration: 
  + Each compute in the fleet runs 10 game server processes with the same launch parameters, which means that each compute can host up to 10 game sessions simultaneously. 
  + On each compute, only two game sessions can be activating at the same time. Activating game sessions must be ready to host players within 300 seconds (5 minutes) or be terminated.
+ Players can connect to game servers using a port in the following range `33435 to 33535`.
+ All game sessions in the fleet have game session protection turned on.
+ Individual players are limited to creating three new game sessions within a 15-minute period.
+ Metrics for this fleet are included in the metric group `AMERfleets`, which (for this example) aggregates metrics for a group of fleets in North, Central, and South America. 

```
aws gamelift create-fleet \
    --name ProdFleet123 \
    --description "A fully configured prod fleet" \
    --ec2-instance-type c5.large \
    --region us-west-2 \
    --locations "Location=sa-east-1" \
    --fleet-type ON_DEMAND \
    --build-id build-1111aaaa-22bb-33cc-44dd-5555eeee66ff \
    --certificate-configuration "CertificateType=GENERATED" \
    --runtime-configuration "GameSessionActivationTimeoutSeconds=300, MaxConcurrentGameSessionActivations=2, ServerProcesses=[{LaunchPath=C:\game\Bin64.dedicated\MultiplayerSampleProjectLauncher_Server.exe, Parameters=+sv_port 33435 +start_lobby, ConcurrentExecutions=10}]" \
    --new-game-session-protection-policy "FullProtection" \
    --resource-creation-limit-policy "NewGameSessionsPerCreator=3, PolicyPeriodInMinutes=15" \
    --ec2-inbound-permissions "FromPort=33435,ToPort=33535,IpRange=0.0.0.0/0,Protocol=UDP" \
    --metric-groups  "AMERfleets"
```

If the create-fleet request is successful, Amazon GameLift Servers returns a set of fleet attributes that includes the configuration settings you requested and a new fleet ID. Amazon GameLift Servers then initiates the fleet activation process and sets the fleet status and the location statuses to **New**. You can track the fleet's status and view other fleet information using these CLI commands: 
+ [describe-fleet-events](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-events.html)
+ [describe-fleet-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-attributes.html)
+ [describe-fleet-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-capacity.html)
+ [describe-fleet-port-settings](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-port-settings.html)
+ [describe-fleet-utilization](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-utilization.html)
+ [describe-runtime-configuration](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-runtime-configuration.html)
+ [describe-fleet-location-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-attributes.html)
+ [describe-fleet-location-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-capacity.html)
+ [describe-fleet-location-utilization](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-utilization.html)

You can change the fleet's capacity and other configuration settings as needed using these commands:
+ [update-fleet-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-attributes.html)
+ [update-fleet-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-capacity.html)
+ [update-fleet-port-settings](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-port-settings.html)
+ [update-runtime-configuration](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-runtime-configuration.html)
+ [create-fleet-locations](https://docs.amazonaws.cn/cli/latest/reference/gamelift/create-fleet-locations.html)
+ [delete-fleet-locations](https://docs.amazonaws.cn/cli/latest/reference/gamelift/delete-fleet-locations.html)

------