CreateContainerGroupDefinition - Amazon GameLift

CreateContainerGroupDefinition

Creates a ContainerGroupDefinition that describes a set of containers for hosting your game server with Amazon GameLift managed containers hosting. An Amazon GameLift container group is similar to a container task or pod. Use container group definitions when you create a container fleet with CreateContainerFleet.

A container group definition determines how Amazon GameLift deploys your containers to each instance in a container fleet. You can maintain multiple versions of a container group definition.

There are two types of container groups:

  • A game server container group has the containers that run your game server application and supporting software. A game server container group can have these container types:

    • Game server container. This container runs your game server. You can define one game server container in a game server container group.

    • Support container. This container runs software in parallel with your game server. You can define up to 8 support containers in a game server group.

    When building a game server container group definition, you can choose to bundle your game server executable and all dependent software into a single game server container. Alternatively, you can separate the software into one game server container and one or more support containers.

    On a container fleet instance, a game server container group can be deployed multiple times (depending on the compute resources of the instance). This means that all containers in the container group are replicated together.

  • A per-instance container group has containers for processes that aren't replicated on a container fleet instance. This might include background services, logging, test processes, or processes that need to persist independently of the game server container group. When building a per-instance container group, you can define up to 10 support containers.

Note

This operation requires AWS Identity and Access Management (IAM) permissions to access container images in Amazon ECR repositories. See IAM permissions for Amazon GameLift for help setting the appropriate permissions.

Request options

Use this operation to make the following types of requests. You can specify values for the minimum required parameters and customize optional values later.

  • Create a game server container group definition. Provide the following required parameter values:

    • Name

    • ContainerGroupType (GAME_SERVER)

    • OperatingSystem (omit to use default value)

    • TotalMemoryLimitMebibytes (omit to use default value)

    • TotalVcpuLimit (omit to use default value)

    • At least one GameServerContainerDefinition

      • ContainerName

      • ImageUrl

      • PortConfiguration

      • ServerSdkVersion (omit to use default value)

  • Create a per-instance container group definition. Provide the following required parameter values:

    • Name

    • ContainerGroupType (PER_INSTANCE)

    • OperatingSystem (omit to use default value)

    • TotalMemoryLimitMebibytes (omit to use default value)

    • TotalVcpuLimit (omit to use default value)

    • At least one SupportContainerDefinition

      • ContainerName

      • ImageUrl

Results

If successful, this request creates a ContainerGroupDefinition resource and assigns a unique ARN value. You can update most properties of a container group definition by calling UpdateContainerGroupDefinition, and optionally save the update as a new version.

Request Syntax

{ "ContainerGroupType": "string", "GameServerContainerDefinition": { "ContainerName": "string", "DependsOn": [ { "Condition": "string", "ContainerName": "string" } ], "EnvironmentOverride": [ { "Name": "string", "Value": "string" } ], "ImageUri": "string", "MountPoints": [ { "AccessLevel": "string", "ContainerPath": "string", "InstancePath": "string" } ], "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": number, "Protocol": "string", "ToPort": number } ] }, "ServerSdkVersion": "string" }, "Name": "string", "OperatingSystem": "string", "SupportContainerDefinitions": [ { "ContainerName": "string", "DependsOn": [ { "Condition": "string", "ContainerName": "string" } ], "EnvironmentOverride": [ { "Name": "string", "Value": "string" } ], "Essential": boolean, "HealthCheck": { "Command": [ "string" ], "Interval": number, "Retries": number, "StartPeriod": number, "Timeout": number }, "ImageUri": "string", "MemoryHardLimitMebibytes": number, "MountPoints": [ { "AccessLevel": "string", "ContainerPath": "string", "InstancePath": "string" } ], "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": number, "Protocol": "string", "ToPort": number } ] }, "Vcpu": number } ], "Tags": [ { "Key": "string", "Value": "string" } ], "TotalMemoryLimitMebibytes": number, "TotalVcpuLimit": number, "VersionDescription": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Note

In the following list, the required parameters are described first.

Name

A descriptive identifier for the container group definition. The name value must be unique in an AWS Region.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9\-]+$

Required: Yes

OperatingSystem

The platform that all containers in the group use. Containers in a group must run on the same operating system.

Default value: AMAZON_LINUX_2023

Note

Amazon Linux 2 (AL2) will reach end of support on 6/30/2025. See more details in the Amazon Linux 2 FAQs. For game servers that are hosted on AL2 and use Amazon GameLift server SDK 4.x, first update the game server build to server SDK 5.x, and then deploy to AL2023 instances. See Migrate to Amazon GameLift server SDK version 5.

Type: String

Valid Values: AMAZON_LINUX_2023

Required: Yes

TotalMemoryLimitMebibytes

The maximum amount of memory (in MiB) to allocate to the container group. All containers in the group share this memory. If you specify memory limits for an individual container, the total value must be greater than any individual container's memory limit.

Default value: 1024

Type: Integer

Valid Range: Minimum value of 4. Maximum value of 1024000.

Required: Yes

TotalVcpuLimit

The maximum amount of vCPU units to allocate to the container group (1 vCPU is equal to 1024 CPU units). All containers in the group share this memory. If you specify vCPU limits for individual containers, the total value must be equal to or greater than the sum of the CPU limits for all containers in the group.

Default value: 1

Type: Double

Valid Range: Minimum value of 0.125. Maximum value of 10.

Required: Yes

ContainerGroupType

The type of container group being defined. Container group type determines how Amazon GameLift deploys the container group on each fleet instance.

Default value: GAME_SERVER

Type: String

Valid Values: GAME_SERVER | PER_INSTANCE

Required: No

GameServerContainerDefinition

The definition for the game server container in this group. Define a game server container only when the container group type is GAME_SERVER. Game server containers specify a container image with your game server build. You can pass in your container definitions as a JSON file.

Type: GameServerContainerDefinitionInput object

Required: No

SupportContainerDefinitions

One or more definition for support containers in this group. You can define a support container in any type of container group. You can pass in your container definitions as a JSON file.

Type: Array of SupportContainerDefinitionInput objects

Array Members: Minimum number of 0 items. Maximum number of 10 items.

Required: No

Tags

A list of labels to assign to the container group definition resource. Tags are developer-defined key-value pairs. Tagging AWS resources are useful for resource management, access management and cost allocation. For more information, see Tagging AWS Resources in the AWS General Reference.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 200 items.

Required: No

VersionDescription

A description for the initial version of this container group definition.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: No

Response Syntax

{ "ContainerGroupDefinition": { "ContainerGroupDefinitionArn": "string", "ContainerGroupType": "string", "CreationTime": number, "GameServerContainerDefinition": { "ContainerName": "string", "DependsOn": [ { "Condition": "string", "ContainerName": "string" } ], "EnvironmentOverride": [ { "Name": "string", "Value": "string" } ], "ImageUri": "string", "MountPoints": [ { "AccessLevel": "string", "ContainerPath": "string", "InstancePath": "string" } ], "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": number, "Protocol": "string", "ToPort": number } ] }, "ResolvedImageDigest": "string", "ServerSdkVersion": "string" }, "Name": "string", "OperatingSystem": "string", "Status": "string", "StatusReason": "string", "SupportContainerDefinitions": [ { "ContainerName": "string", "DependsOn": [ { "Condition": "string", "ContainerName": "string" } ], "EnvironmentOverride": [ { "Name": "string", "Value": "string" } ], "Essential": boolean, "HealthCheck": { "Command": [ "string" ], "Interval": number, "Retries": number, "StartPeriod": number, "Timeout": number }, "ImageUri": "string", "MemoryHardLimitMebibytes": number, "MountPoints": [ { "AccessLevel": "string", "ContainerPath": "string", "InstancePath": "string" } ], "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": number, "Protocol": "string", "ToPort": number } ] }, "ResolvedImageDigest": "string", "Vcpu": number } ], "TotalMemoryLimitMebibytes": number, "TotalVcpuLimit": number, "VersionDescription": "string", "VersionNumber": number } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ContainerGroupDefinition

The properties of the new container group definition resource. You can use this resource to create a container fleet.

Type: ContainerGroupDefinition object

Errors

For information about the errors that are common to all actions, see Common Errors.

ConflictException

The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.

HTTP Status Code: 400

InternalServiceException

The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

HTTP Status Code: 500

InvalidRequestException

One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

HTTP Status Code: 400

LimitExceededException

The requested operation would cause the resource to exceed the allowed service limit. Resolve the issue before retrying.

HTTP Status Code: 400

TaggingFailedException

The requested tagging operation did not succeed. This may be due to invalid tag format or the maximum tag limit may have been exceeded. Resolve the issue before retrying.

HTTP Status Code: 400

UnauthorizedException

The client failed authentication. Clients should not retry such requests.

HTTP Status Code: 400

UnsupportedRegionException

The requested operation is not supported in the Region specified.

HTTP Status Code: 400

Examples

Create a simple game server container group definition

This example creates a game server container group definition with a game server container definition. The request includes the minimal parameter settings and uses the default values for all other parameters. The container definition has these characteristics:

  • It defines a container port range, which is required for containers that run game server processes.

  • The image URI points to an ECR private repo.

  • It doesn't need a health check configuration. Amazon GameLift handles the health checks for a game server container.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

Sample Request

{ "Name": "MyAdventureGameContainerGroup", "ContainerGroupType": "GAME_SERVER", "GameServerContainerDefinition": [ { "ContainerName": "MyAdventureGameServer", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage", "ServerSdkVersion": 5.2.0, "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": 35000, "Protocol": "UDP", "ToPort": 40000 } ] } } ] }

Sample Response

{ "ContainerGroupDefinition": { "ContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2:111122223333:containergroupdefinition/MyAdventureGameContainerGroup:1", "ContainerGroupType": "GAME_SERVER", "CreationTime": 1496365885.44, "GameServerContainerDefinition": [ { "ContainerName": "MyAdventureGameServer", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage", "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": 35000, "Protocol": "TCP", "ToPort": 40000 } ] }, "ResolvedImageDigest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "ServerSdkVersion": "5.2.0" } ], "Name": "MyAdventureGameContainerGroup", "OperatingSystem": "AMAZON_LINUX_2023", "Status": "COPYING", "TotalMemoryLimitMebibytes": 1024, "TotalVcpuLimit": 1, "VersionNumber": "1" } }

Create a game server container with support containers

This example creates a game server container group definition with a game server container definition and one support container The request includes the minimal parameter settings and uses the default values for all other parameters.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

Sample Request

{ "Name": "MyAdventureGameContainerGroup", "ContainerGroupType": "GAME_SERVER", "GameServerContainerDefinition": [ { "ContainerName": "MyAdventureGameServer", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage", "ServerSdkVersion": 5.2.0, "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": 35000, "Protocol": "UDP", "ToPort": 40000 } ] } } ], "SupportContainerDefinitions": [ { "ContainerName": "MyAdventureGameDependencies", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage" } ] }

Sample Response

{ "ContainerGroupDefinition": { "ContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2:111122223333:containergroupdefinition/MyAdventureGameContainerGroup:1", "ContainerGroupType": "GAME_SERVER", "CreationTime": 1496365885.44, "GameServerContainerDefinition": [ { "ContainerName": "MyAdventureGameContainer", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage", "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": 35000, "Protocol": "TCP", "ToPort": 40000 } ] }, "ResolvedImageDigest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "ServerSdkVersion": "5.2.0" } ], "Name": "MyAdventureGameContainerGroup", "OperatingSystem": "AMAZON_LINUX_2023", "Status": "READY", "SupportContainerDefinitions": [ { "ContainerName": "MyAdventureGameDependencies", "ImageUri": "111122223333.dkr.ecr.us-west-2.amazonaws.com/MyAdventureGameContainerImage" } ], "TotalMemoryLimitMebibytes": 1024, "TotalVcpuLimit": 1, "VersionNumber": "1" } }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: