CreateContainerGroupDefinitionCommand

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.

This operation requires 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.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { GameLiftClient, CreateContainerGroupDefinitionCommand } from "@aws-sdk/client-gamelift"; // ES Modules import
// const { GameLiftClient, CreateContainerGroupDefinitionCommand } = require("@aws-sdk/client-gamelift"); // CommonJS import
const client = new GameLiftClient(config);
const input = { // CreateContainerGroupDefinitionInput
  Name: "STRING_VALUE", // required
  ContainerGroupType: "GAME_SERVER" || "PER_INSTANCE",
  TotalMemoryLimitMebibytes: Number("int"), // required
  TotalVcpuLimit: Number("double"), // required
  GameServerContainerDefinition: { // GameServerContainerDefinitionInput
    ContainerName: "STRING_VALUE", // required
    DependsOn: [ // ContainerDependencyList
      { // ContainerDependency
        ContainerName: "STRING_VALUE", // required
        Condition: "START" || "COMPLETE" || "SUCCESS" || "HEALTHY", // required
      },
    ],
    MountPoints: [ // ContainerMountPointList
      { // ContainerMountPoint
        InstancePath: "STRING_VALUE", // required
        ContainerPath: "STRING_VALUE",
        AccessLevel: "READ_ONLY" || "READ_AND_WRITE",
      },
    ],
    EnvironmentOverride: [ // ContainerEnvironmentList
      { // ContainerEnvironment
        Name: "STRING_VALUE", // required
        Value: "STRING_VALUE", // required
      },
    ],
    ImageUri: "STRING_VALUE", // required
    PortConfiguration: { // ContainerPortConfiguration
      ContainerPortRanges: [ // ContainerPortRangeList // required
        { // ContainerPortRange
          FromPort: Number("int"), // required
          ToPort: Number("int"), // required
          Protocol: "TCP" || "UDP", // required
        },
      ],
    },
    ServerSdkVersion: "STRING_VALUE", // required
  },
  SupportContainerDefinitions: [ // SupportContainerDefinitionInputList
    { // SupportContainerDefinitionInput
      ContainerName: "STRING_VALUE", // required
      DependsOn: [
        {
          ContainerName: "STRING_VALUE", // required
          Condition: "START" || "COMPLETE" || "SUCCESS" || "HEALTHY", // required
        },
      ],
      MountPoints: [
        {
          InstancePath: "STRING_VALUE", // required
          ContainerPath: "STRING_VALUE",
          AccessLevel: "READ_ONLY" || "READ_AND_WRITE",
        },
      ],
      EnvironmentOverride: [
        {
          Name: "STRING_VALUE", // required
          Value: "STRING_VALUE", // required
        },
      ],
      Essential: true || false,
      HealthCheck: { // ContainerHealthCheck
        Command: [ // ContainerCommandStringList // required
          "STRING_VALUE",
        ],
        Interval: Number("int"),
        Retries: Number("int"),
        StartPeriod: Number("int"),
        Timeout: Number("int"),
      },
      ImageUri: "STRING_VALUE", // required
      MemoryHardLimitMebibytes: Number("int"),
      PortConfiguration: {
        ContainerPortRanges: [ // required
          {
            FromPort: Number("int"), // required
            ToPort: Number("int"), // required
            Protocol: "TCP" || "UDP", // required
          },
        ],
      },
      Vcpu: Number("double"),
    },
  ],
  OperatingSystem: "AMAZON_LINUX_2023", // required
  VersionDescription: "STRING_VALUE",
  Tags: [ // TagList
    { // Tag
      Key: "STRING_VALUE", // required
      Value: "STRING_VALUE", // required
    },
  ],
};
const command = new CreateContainerGroupDefinitionCommand(input);
const response = await client.send(command);
// { // CreateContainerGroupDefinitionOutput
//   ContainerGroupDefinition: { // ContainerGroupDefinition
//     ContainerGroupDefinitionArn: "STRING_VALUE",
//     CreationTime: new Date("TIMESTAMP"),
//     OperatingSystem: "AMAZON_LINUX_2023",
//     Name: "STRING_VALUE", // required
//     ContainerGroupType: "GAME_SERVER" || "PER_INSTANCE",
//     TotalMemoryLimitMebibytes: Number("int"),
//     TotalVcpuLimit: Number("double"),
//     GameServerContainerDefinition: { // GameServerContainerDefinition
//       ContainerName: "STRING_VALUE",
//       DependsOn: [ // ContainerDependencyList
//         { // ContainerDependency
//           ContainerName: "STRING_VALUE", // required
//           Condition: "START" || "COMPLETE" || "SUCCESS" || "HEALTHY", // required
//         },
//       ],
//       MountPoints: [ // ContainerMountPointList
//         { // ContainerMountPoint
//           InstancePath: "STRING_VALUE", // required
//           ContainerPath: "STRING_VALUE",
//           AccessLevel: "READ_ONLY" || "READ_AND_WRITE",
//         },
//       ],
//       EnvironmentOverride: [ // ContainerEnvironmentList
//         { // ContainerEnvironment
//           Name: "STRING_VALUE", // required
//           Value: "STRING_VALUE", // required
//         },
//       ],
//       ImageUri: "STRING_VALUE",
//       PortConfiguration: { // ContainerPortConfiguration
//         ContainerPortRanges: [ // ContainerPortRangeList // required
//           { // ContainerPortRange
//             FromPort: Number("int"), // required
//             ToPort: Number("int"), // required
//             Protocol: "TCP" || "UDP", // required
//           },
//         ],
//       },
//       ResolvedImageDigest: "STRING_VALUE",
//       ServerSdkVersion: "STRING_VALUE",
//     },
//     SupportContainerDefinitions: [ // SupportContainerDefinitionList
//       { // SupportContainerDefinition
//         ContainerName: "STRING_VALUE",
//         DependsOn: [
//           {
//             ContainerName: "STRING_VALUE", // required
//             Condition: "START" || "COMPLETE" || "SUCCESS" || "HEALTHY", // required
//           },
//         ],
//         MountPoints: [
//           {
//             InstancePath: "STRING_VALUE", // required
//             ContainerPath: "STRING_VALUE",
//             AccessLevel: "READ_ONLY" || "READ_AND_WRITE",
//           },
//         ],
//         EnvironmentOverride: [
//           {
//             Name: "STRING_VALUE", // required
//             Value: "STRING_VALUE", // required
//           },
//         ],
//         Essential: true || false,
//         HealthCheck: { // ContainerHealthCheck
//           Command: [ // ContainerCommandStringList // required
//             "STRING_VALUE",
//           ],
//           Interval: Number("int"),
//           Retries: Number("int"),
//           StartPeriod: Number("int"),
//           Timeout: Number("int"),
//         },
//         ImageUri: "STRING_VALUE",
//         MemoryHardLimitMebibytes: Number("int"),
//         PortConfiguration: {
//           ContainerPortRanges: [ // required
//             {
//               FromPort: Number("int"), // required
//               ToPort: Number("int"), // required
//               Protocol: "TCP" || "UDP", // required
//             },
//           ],
//         },
//         ResolvedImageDigest: "STRING_VALUE",
//         Vcpu: Number("double"),
//       },
//     ],
//     VersionNumber: Number("int"),
//     VersionDescription: "STRING_VALUE",
//     Status: "READY" || "COPYING" || "FAILED",
//     StatusReason: "STRING_VALUE",
//   },
// };

CreateContainerGroupDefinitionCommand Input

Parameter
Type
Description
Name
Required
string | undefined

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

OperatingSystem
Required
ContainerOperatingSystem | undefined

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

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 server SDK version 4.x for Amazon GameLift, first update the game server build to server SDK 5.x, and then deploy to AL2023 instances. See Migrate to server SDK version 5. 

TotalMemoryLimitMebibytes
Required
number | undefined

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

TotalVcpuLimit
Required
number | undefined

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

ContainerGroupType
ContainerGroupType | undefined

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

GameServerContainerDefinition
GameServerContainerDefinitionInput | undefined

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.

SupportContainerDefinitions
SupportContainerDefinitionInput[] | undefined

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.

Tags
Tag[] | undefined

A list of labels to assign to the container group definition 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.

VersionDescription
string | undefined

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

CreateContainerGroupDefinitionCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
ContainerGroupDefinition
ContainerGroupDefinition | undefined

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

Throws

Name
Fault
Details
ConflictException
client

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.

InternalServiceException
server

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

InvalidRequestException
client

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

LimitExceededException
client

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

TaggingFailedException
client

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.

UnauthorizedException
client

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

UnsupportedRegionException
client

The requested operation is not supported in the Region specified.

GameLiftServiceException
Base exception class for all service exceptions from GameLift service.