The AWS::GameLift::Fleet resource creates an Amazon GameLift (GameLift) fleet to host game servers. A fleet is a set of EC2 or Anywhere instances, each of which can host multiple game sessions.
IMPORTANT: The S3 permissions listed in the example are meant for testing purposes only. Restrict these permissions further for enhanced security. Amazon GameLift Fleets can take some time to finish activating. This can lead to a long-running (>25min) terraform apply
and is normal. If you encounter errors with your fleet not activating successfully, check the troubleshooting steps listed in this doc.
To use awscc_gamelift_fleet to create a GameLift Fleet:
resource "awscc_gamelift_fleet" "example" {
name = "ExampleFleet"
build_id = awscc_gamelift_build.example.id
compute_type = "EC2"
ec2_instance_type = "c5.large"
fleet_type = "ON_DEMAND"
runtime_configuration = {
server_processes = [
{
concurrent_executions = 1
launch_path = "/local/game/path-to-your-file"
parameters = "yourParameterKey:yourParameterValue yourParameterKey2:YourParameterValue2"
},
{
concurrent_executions = 1
launch_path = "/local/game/path-to-your-file"
parameters = "yourParameterKey:yourParameterValue yourParameterKey2:YourParameterValue2"
},
]
}
}
resource "awscc_gamelift_build" "example" {
name = "ExampleBuild"
version = "1.0"
operating_system = "AMAZON_LINUX_2"
storage_location = {
bucket = "your-s3-bucket"
key = "your-s3-key"
role_arn = awscc_iam_role.example.arn
}
}
resource "awscc_iam_role" "example" {
role_name = "gamelift-s3-access"
description = "This IAM role grants Amazon GameLift access to the S3 bucket containing build files"
assume_role_policy_document = data.aws_iam_policy_document.instance_assume_role_policy.json
managed_policy_arns = [aws_iam_policy.example.arn]
max_session_duration = 7200
path = "/"
tags = [
{
key = "Environment"
value = "Development"
},
{
key = "Modified By"
value = "AWSCC"
}
]
}
data "aws_iam_policy_document" "instance_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["gamelift.amazonaws.com"]
}
}
}
resource "aws_iam_policy" "example" {
name = "gamelift-s3-access-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = ["s3:*"]
Resource = "*"
},
]
})
}
name
(String) A descriptive label that is associated with a fleet. Fleet names do not need to be unique.anywhere_configuration
(Attributes) Configuration for Anywhere fleet. (see below for nested schema)apply_capacity
(String) Determines whether to apply fleet or location capacities on fleet creation.build_id
(String) A unique identifier for a build to be deployed on the new fleet. If you are deploying the fleet with a custom game build, you must specify this property. 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.certificate_configuration
(Attributes) Indicates whether to generate a TLS/SSL certificate for the new fleet. TLS certificates are used for encrypting traffic between game clients and game servers running on GameLift. If this parameter is not set, certificate generation is disabled. This fleet setting cannot be changed once the fleet is created. (see below for nested schema)compute_type
(String) ComputeType to differentiate EC2 hardware managed by GameLift and Anywhere hardware managed by the customer.container_groups_configuration
(Attributes) Specifies container groups that this instance will hold. You must specify exactly one replica group. Optionally, you may specify exactly one daemon group. You can't change this property after you create the fleet. (see below for nested schema)description
(String) A human-readable description of a fleet.desired_ec2_instances
(Number) [DEPRECATED] The number of EC2 instances that you want this fleet to host. 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.ec2_inbound_permissions
(Attributes List) A range of IP addresses and port settings that allow inbound traffic to connect to server processes on an Amazon GameLift server. (see below for nested schema)ec2_instance_type
(String) The name of an EC2 instance type that is supported in Amazon GameLift. A fleet instance type determines the computing resources of each instance in the fleet, including CPU, memory, storage, and networking capacity. Amazon GameLift supports the following EC2 instance types. See Amazon EC2 Instance Types for detailed descriptions.fleet_type
(String) Indicates whether to use On-Demand instances or Spot instances for this fleet. If empty, the default is ON_DEMAND. Both categories of instances use identical hardware and configurations based on the instance type selected for this fleet.instance_role_arn
(String) A unique identifier for an AWS IAM role that manages access to your AWS 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 from the IAM dashboard in the AWS Management Console.instance_role_credentials_provider
(String) Credentials provider implementation that loads credentials from the Amazon EC2 Instance Metadata Service.locations
(Attributes List) (see below for nested schema)log_paths
(List of String) This parameter is no longer used. When hosting a custom game build, specify where Amazon GameLift should store log files using the Amazon GameLift server API call ProcessReady()max_size
(Number) [DEPRECATED] The maximum value that is allowed for the fleet's instance count. When creating a new fleet, GameLift automatically sets this value to "1". Once the fleet is active, you can change this value.metric_groups
(List of String) The name of an Amazon CloudWatch metric group. A metric group aggregates the metrics for all fleets in the group. Specify a string containing the metric group name. You can use an existing name or use a new name to create a new metric group. Currently, this parameter can have only one string.min_size
(Number) [DEPRECATED] The minimum value allowed for the fleet's instance count. When creating a new fleet, GameLift automatically sets this value to "0". After the fleet is active, you can change this value.new_game_session_protection_policy
(String) A game session protection policy to apply to all game sessions hosted on instances in this fleet. When protected, active game sessions cannot be terminated during a scale-down event. If this parameter is not set, instances in this fleet default to no protection. You can change a fleet's protection policy to affect future game sessions on the fleet. You can also set protection for individual game sessions.peer_vpc_aws_account_id
(String) A unique identifier for the AWS account with the VPC that you want to peer your Amazon GameLift fleet with. You can find your account ID in the AWS Management Console under account settings.peer_vpc_id
(String) A unique identifier for a VPC with resources to be accessed by your Amazon GameLift fleet. The VPC must be in the same Region as your fleet. To look up a VPC ID, use the VPC Dashboard in the AWS Management Console.resource_creation_limit_policy
(Attributes) A policy that limits the number of game sessions an individual player can create over a span of time for this fleet. (see below for nested schema)runtime_configuration
(Attributes) Instructions for launching server processes on each instance in the fleet. Server processes run either a custom game build executable or a Realtime script. The runtime configuration defines the server executables or launch script file, launch parameters, and the number of processes to run concurrently on each instance. When creating a fleet, the runtime configuration must have at least one server process configuration; otherwise the request fails with an invalid request exception.This parameter is required unless the parameters ServerLaunchPath and ServerLaunchParameters are defined. Runtime configuration has replaced these parameters, but fleets that use them will continue to work. (see below for nested schema)
scaling_policies
(Attributes List) A list of rules that control how a fleet is scaled. (see below for nested schema)script_id
(String) A unique identifier for a Realtime script to be deployed on a new Realtime Servers fleet. The script must have been successfully uploaded to Amazon GameLift. This fleet setting cannot be changed once the fleet is created.Note: It is not currently possible to use the !Ref command to reference a script created with a CloudFormation template for the fleet property ScriptId. Instead, use Fn::GetAtt Script.Arn or Fn::GetAtt Script.Id to retrieve either of these properties as input for ScriptId. Alternatively, enter a ScriptId string manually.
server_launch_parameters
(String) This parameter is no longer used but is retained for backward compatibility. Instead, specify server launch parameters in the RuntimeConfiguration parameter. A request must specify either a runtime configuration or values for both ServerLaunchParameters and ServerLaunchPath.server_launch_path
(String) This parameter is no longer used. Instead, specify a server launch path using the RuntimeConfiguration parameter. Requests that specify a server launch path and launch parameters instead of a runtime configuration will continue to work.fleet_id
(String) Unique fleet IDid
(String) Uniquely identifies the resource.anywhere_configuration
Required:
cost
(String) Cost of compute can be specified on Anywhere Fleets to prioritize placement across Queue destinations based on Cost.certificate_configuration
Required:
certificate_type
(String)container_groups_configuration
Required:
connection_port_range
(Attributes) Defines the range of ports on the instance that allow inbound traffic to connect with containers in a fleet. (see below for nested schema)container_group_definition_names
(List of String) The names of the container group definitions that will be created in an instance. You must specify exactly one REPLICA container group. You have the option to also specify one DAEMON container group.Optional:
container_groups_per_instance
(Attributes) The number of container groups per instance. (see below for nested schema)container_groups_configuration.connection_port_range
Required:
from_port
(Number) A starting value for a range of allowed port numbers.to_port
(Number) An ending value for a range of allowed port numbers. Port numbers are end-inclusive. This value must be higher than FromPort.container_groups_configuration.container_groups_per_instance
Optional:
desired_replica_container_groups_per_instance
(Number) Use this parameter to override the number of replica container groups GameLift will launch per instance with a number that is lower than that calculated maximum.Read-Only:
max_replica_container_groups_per_instance
(Number) GameLift calculates the maximum number of replica container groups it can launch per instance based on instance properties such as CPU, memory, and connection ports.ec2_inbound_permissions
Required:
from_port
(Number) A starting value for a range of allowed port numbers.ip_range
(String) A range of allowed IP addresses. This value must be expressed in CIDR notation. Example: "000.000.000.000/[subnet mask]" or optionally the shortened version "0.0.0.0/[subnet mask]".protocol
(String) The network communication protocol used by the fleet.to_port
(Number) An ending value for a range of allowed port numbers. Port numbers are end-inclusive. This value must be higher than FromPort.locations
Required:
location
(String)Optional:
location_capacity
(Attributes) Current resource capacity settings in a specified fleet or location. The location value might refer to a fleet's remote location or its home Region. (see below for nested schema)locations.location_capacity
Required:
desired_ec2_instances
(Number) The number of EC2 instances you want to maintain in the specified fleet location. This value must fall between the minimum and maximum size limits.max_size
(Number) The maximum value that is allowed for the fleet's instance count for a location. When creating a new fleet, GameLift automatically sets this value to "1". Once the fleet is active, you can change this value.min_size
(Number) The minimum value allowed for the fleet's instance count for a location. When creating a new fleet, GameLift automatically sets this value to "0". After the fleet is active, you can change this value.resource_creation_limit_policy
Optional:
new_game_sessions_per_creator
(Number) The maximum number of game sessions that an individual can create during the policy period.policy_period_in_minutes
(Number) The time span used in evaluating the resource creation limit policy.runtime_configuration
Optional:
game_session_activation_timeout_seconds
(Number) The maximum amount of time (in seconds) that a game session can remain in status ACTIVATING. If the game session is not active before the timeout, activation is terminated and the game session status is changed to TERMINATED.max_concurrent_game_session_activations
(Number) The maximum number of game sessions with status ACTIVATING to allow on an instance simultaneously. This setting limits the amount of instance resources that can be used for new game activations at any one time.server_processes
(Attributes List) A collection of server process configurations that describe which server processes to run on each instance in a fleet. (see below for nested schema)runtime_configuration.server_processes
Required:
concurrent_executions
(Number) The number of server processes that use this configuration to run concurrently on an instance.launch_path
(String) The location of the server executable in a custom game build or the name of the Realtime script file that contains the Init() function. Game builds and Realtime scripts are installed on instances at the root:Windows (for custom game builds only): C:\game. Example: "C:\game\MyGame\server.exe"
Linux: /local/game. Examples: "/local/game/MyGame/server.exe" or "/local/game/MyRealtimeScript.js"
Optional:
parameters
(String) An optional list of parameters to pass to the server executable or Realtime script on launch.scaling_policies
Required:
metric_name
(String) Name of the Amazon GameLift-defined metric that is used to trigger a scaling adjustment.name
(String) A descriptive label that is associated with a fleet's scaling policy. Policy names do not need to be unique.Optional:
comparison_operator
(String) Comparison operator to use when measuring a metric against the threshold value.evaluation_periods
(Number) Length of time (in minutes) the metric must be at or beyond the threshold before a scaling event is triggered.location
(String)policy_type
(String) The type of scaling policy to create. For a target-based policy, set the parameter MetricName to 'PercentAvailableGameSessions' and specify a TargetConfiguration. For a rule-based policy set the following parameters: MetricName, ComparisonOperator, Threshold, EvaluationPeriods, ScalingAdjustmentType, and ScalingAdjustment.scaling_adjustment
(Number) Amount of adjustment to make, based on the scaling adjustment type.scaling_adjustment_type
(String) The type of adjustment to make to a fleet's instance count.status
(String) Current status of the scaling policy. The scaling policy can be in force only when in an ACTIVE status. Scaling policies can be suspended for individual fleets. If the policy is suspended for a fleet, the policy status does not change.target_configuration
(Attributes) An object that contains settings for a target-based scaling policy. (see below for nested schema)threshold
(Number) Metric value used to trigger a scaling event.update_status
(String) The current status of the fleet's scaling policies in a requested fleet location. The status PENDING_UPDATE indicates that an update was requested for the fleet but has not yet been completed for the location.scaling_policies.target_configuration
Required:
target_value
(Number) Desired value to use with a target-based scaling policy. The value must be relevant for whatever metric the scaling policy is using. For example, in a policy using the metric PercentAvailableGameSessions, the target value should be the preferred size of the fleet's buffer (the percent of capacity that should be idle and ready for new game sessions).Import is supported using the following syntax:
$ terraform import awscc_gamelift_fleet.example <resource ID>