awscc_gamelift_fleet (Resource)

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.

Example Usage

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 = "*"
      },
    ]
  })
}

Schema

Required

Optional

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)

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.

Read-Only

Nested Schema for anywhere_configuration

Required:

Nested Schema for certificate_configuration

Required:

Nested Schema for container_groups_configuration

Required:

Optional:

Nested Schema for container_groups_configuration.connection_port_range

Required:

Nested Schema for container_groups_configuration.container_groups_per_instance

Optional:

Read-Only:

Nested Schema for ec2_inbound_permissions

Required:

Nested Schema for locations

Required:

Optional:

Nested Schema for locations.location_capacity

Required:

Nested Schema for resource_creation_limit_policy

Optional:

Nested Schema for runtime_configuration

Optional:

Nested Schema for runtime_configuration.server_processes

Required:

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:

Nested Schema for scaling_policies

Required:

Optional:

Nested Schema for scaling_policies.target_configuration

Required:

Import

Import is supported using the following syntax:

$ terraform import awscc_gamelift_fleet.example <resource ID>