Skip to content

create_container_group_definition

create_container_group_definition(
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    name: Optional[ContainerGroupDefinitionName] = None,
    container_group_type: Optional[ContainerGroupType] = None,
    total_memory_limit_mebibytes: Optional[ContainerTotalMemoryLimit] = None,
    total_vcpu_limit: Optional[ContainerTotalVcpuLimit] = None,
    game_server_container_definition: Optional[
        GameServerContainerDefinitionInput
    ] = None,
    support_container_definitions: Optional[SupportContainerDefinitionInputList] = None,
    operating_system: Optional[ContainerOperatingSystem] = None,
    version_description: Optional[NonZeroAndMaxString] = None,
    tags: Optional[TagList] = None,
) -> CreateContainerGroupDefinitionOutput

This API works with the following fleet types: Container

Creates a ContainerGroupDefinition that describes a set of containers for hosting your game server with Amazon GameLift Servers managed containers hosting. An Amazon GameLift Servers 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 Servers 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 Servers 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

    • TotalMemoryLimitMebibytes

    • Either TotalVcpuLimit or a Vcpu value for the game server container

    • At least one GameServerContainerDefinition

      • ContainerName

      • ImageUrl

      • PortConfiguration

      • ServerSdkVersion

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

    • Name

    • ContainerGroupType (PER_INSTANCE)

    • OperatingSystem

    • TotalMemoryLimitMebibytes

    • TotalVcpuLimit

    • 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.

Parameters:

  • name (Optional[ContainerGroupDefinitionName], default: None ) –

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

  • container_group_type (Optional[ContainerGroupType], default: None ) –

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

    Default value: GAME_SERVER

  • total_memory_limit_mebibytes (Optional[ContainerTotalMemoryLimit], default: None ) –

    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

  • total_vcpu_limit (Optional[ContainerTotalVcpuLimit], default: None ) –

    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 these resources. If you set vCPU reservations for individual containers, the total value must be equal to or greater than the sum of the Vcpu values for all containers in the group.

    This property is required for a per-instance container group.

    For a game server container group, Amazon GameLift Servers requires either a total vCPU limit or a Vcpu value for the game server container. If you set a total vCPU limit for a game server container group, Amazon GameLift Servers uses this value to calculate how many game server container groups fit on an instance. If you don't set a total vCPU limit, the group's containers can use up to the instance's available vCPU, and Amazon GameLift Servers uses the sum of the containers' Vcpu values to calculate how many game server container groups fit on an instance.

  • game_server_container_definition (Optional[GameServerContainerDefinitionInput], default: None ) –

    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.

  • support_container_definitions (Optional[SupportContainerDefinitionInputList], default: None ) –

    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.

  • operating_system (Optional[ContainerOperatingSystem], default: None ) –

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

  • version_description (Optional[NonZeroAndMaxString], default: None ) –

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

  • tags (Optional[TagList], default: None ) –

    A list of labels to assign to the container group definition resource. Tags are developer-defined key-value pairs. Tagging Amazon Web Services resources is 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.

Raises:

  • 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.

  • InternalServiceException –

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

  • InvalidRequestException –

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

  • LimitExceededException –

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

  • 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.

  • UnauthorizedException –

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

  • UnsupportedRegionException –

    The requested operation is not supported in the Region specified.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_gamelift/_services/game_lift.py
def create_container_group_definition(
    self,
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    name: Optional[
        "capo_gamelift.types.container_group_definition_name.ContainerGroupDefinitionName"
    ] = None,
    container_group_type: Optional[
        "capo_gamelift.types.container_group_type.ContainerGroupType"
    ] = None,
    total_memory_limit_mebibytes: Optional[
        "capo_gamelift.types.container_total_memory_limit.ContainerTotalMemoryLimit"
    ] = None,
    total_vcpu_limit: Optional[
        "capo_gamelift.types.container_total_vcpu_limit.ContainerTotalVcpuLimit"
    ] = None,
    game_server_container_definition: Optional[
        "capo_gamelift.types.game_server_container_definition_input.GameServerContainerDefinitionInput"
    ] = None,
    support_container_definitions: Optional[
        "capo_gamelift.types.support_container_definition_input_list.SupportContainerDefinitionInputList"
    ] = None,
    operating_system: Optional[
        "capo_gamelift.types.container_operating_system.ContainerOperatingSystem"
    ] = None,
    version_description: Optional[
        "capo_gamelift.types.non_zero_and_max_string.NonZeroAndMaxString"
    ] = None,
    tags: Optional["capo_gamelift.types.tag_list.TagList"] = None,
) -> "capo_gamelift.types.create_container_group_definition_output.CreateContainerGroupDefinitionOutput":
    """<p> <b>This API works with the following fleet types:</b> Container</p> <p>Creates a <code>ContainerGroupDefinition</code> that describes a set of containers for hosting your game server with Amazon GameLift Servers managed containers hosting. An Amazon GameLift Servers container group is similar to a container task or pod. Use container group definitions when you create a container fleet with <a href="https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreateContainerFleet.html">CreateContainerFleet</a>. </p> <p>A container group definition determines how Amazon GameLift Servers deploys your containers to each instance in a container fleet. You can maintain multiple versions of a container group definition.</p> <p>There are two types of container groups:</p> <ul> <li> <p>A <b>game server container group</b> has the containers that run your game server application and supporting software. A game server container group can have these container types:</p> <ul> <li> <p>Game server container. This container runs your game server. You can define one game server container in a game server container group.</p> </li> <li> <p>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.</p> </li> </ul> <p>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.</p> <p>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.</p> </li> <li> <p>A <b>per-instance container group</b> 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.</p> </li> </ul> <note> <p>This operation requires Identity and Access Management (IAM) permissions to access container images in Amazon ECR repositories. See <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-iam-policy-examples.html"> IAM permissions for Amazon GameLift Servers</a> for help setting the appropriate permissions.</p> </note> <p> <b>Request options</b> </p> <p>Use this operation to make the following types of requests. You can specify values for the minimum required parameters and customize optional values later.</p> <ul> <li> <p>Create a game server container group definition. Provide the following required parameter values:</p> <ul> <li> <p> <code>Name</code> </p> </li> <li> <p> <code>ContainerGroupType</code> (<code>GAME_SERVER</code>)</p> </li> <li> <p> <code>OperatingSystem</code> </p> </li> <li> <p> <code>TotalMemoryLimitMebibytes</code> </p> </li> <li> <p>Either <code>TotalVcpuLimit</code> or a <code>Vcpu</code> value for the game server container</p> </li> <li> <p>At least one <code>GameServerContainerDefinition</code> </p> <ul> <li> <p> <code>ContainerName</code> </p> </li> <li> <p> <code>ImageUrl</code> </p> </li> <li> <p> <code>PortConfiguration</code> </p> </li> <li> <p> <code>ServerSdkVersion</code> </p> </li> </ul> </li> </ul> </li> <li> <p>Create a per-instance container group definition. Provide the following required parameter values:</p> <ul> <li> <p> <code>Name</code> </p> </li> <li> <p> <code>ContainerGroupType</code> (<code>PER_INSTANCE</code>)</p> </li> <li> <p> <code>OperatingSystem</code> </p> </li> <li> <p> <code>TotalMemoryLimitMebibytes</code> </p> </li> <li> <p> <code>TotalVcpuLimit</code> </p> </li> <li> <p>At least one <code>SupportContainerDefinition</code> </p> <ul> <li> <p> <code>ContainerName</code> </p> </li> <li> <p> <code>ImageUrl</code> </p> </li> </ul> </li> </ul> </li> </ul> <p> <b>Results</b> </p> <p>If successful, this request creates a <code>ContainerGroupDefinition</code> resource and assigns a unique ARN value. You can update most properties of a container group definition by calling <a href="https://docs.aws.amazon.com/gamelift/latest/apireference/API_UpdateContainerGroupDefinition.html">UpdateContainerGroupDefinition</a>, and optionally save the update as a new version.</p>

    Args:
        name: <p>A descriptive identifier for the container group definition. The name value must be unique in an Amazon Web Services Region.</p>
        container_group_type: <p>The type of container group being defined. Container group type determines how Amazon GameLift Servers deploys the container group on each fleet instance.</p> <p>Default value: <code>GAME_SERVER</code> </p>
        total_memory_limit_mebibytes: <p>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.</p> <p>Default value: 1024</p>
        total_vcpu_limit: <p>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 these resources. If you set vCPU reservations for individual containers, the total value must be equal to or greater than the sum of the <code>Vcpu</code> values for all containers in the group.</p> <p>This property is required for a per-instance container group.</p> <p>For a game server container group, Amazon GameLift Servers requires either a total vCPU limit or a <code>Vcpu</code> value for the game server container. If you set a total vCPU limit for a game server container group, Amazon GameLift Servers uses this value to calculate how many game server container groups fit on an instance. If you don't set a total vCPU limit, the group's containers can use up to the instance's available vCPU, and Amazon GameLift Servers uses the sum of the containers' <code>Vcpu</code> values to calculate how many game server container groups fit on an instance.</p>
        game_server_container_definition: <p>The definition for the game server container in this group. Define a game server container only when the container group type is <code>GAME_SERVER</code>. Game server containers specify a container image with your game server build. You can pass in your container definitions as a JSON file.</p>
        support_container_definitions: <p>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.</p>
        operating_system: <p>The platform that all containers in the group use. Containers in a group must run on the same operating system.</p> <p>Default value: <code>AMAZON_LINUX_2023</code> </p> <note> <p>Amazon Linux 2 (AL2) will reach end of support on 6/30/2026. See more details in the <a href="http://aws.amazon.com/amazon-linux-2/faqs/">Amazon Linux 2 FAQs</a>. For game servers that are hosted on AL2 and use server SDK version 4.x for Amazon GameLift Servers, first update the game server build to server SDK 5.x, and then deploy to AL2023 instances. See <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-serversdk5-migration.html"> Migrate to server SDK version 5.</a> </p> </note>
        version_description: <p>A description for the initial version of this container group definition. </p>
        tags: <p>A list of labels to assign to the container group definition resource. Tags are developer-defined key-value pairs. Tagging Amazon Web Services resources is useful for resource management, access management and cost allocation. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html"> Tagging Amazon Web Services Resources</a> in the <i>Amazon Web Services General Reference</i>. </p>

    Raises:
        capo_gamelift.errors.conflict_exception.ConflictException: <p>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.</p> <p></p>
        capo_gamelift.errors.internal_service_exception.InternalServiceException: <p>The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.</p>
        capo_gamelift.errors.invalid_request_exception.InvalidRequestException: <p>One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.</p>
        capo_gamelift.errors.limit_exceeded_exception.LimitExceededException: <p>The requested operation would cause the resource to exceed the allowed service limit. Resolve the issue before retrying.</p>
        capo_gamelift.errors.tagging_failed_exception.TaggingFailedException: <p>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.</p>
        capo_gamelift.errors.unauthorized_exception.UnauthorizedException: <p>The client failed authentication. Clients should not retry such requests.</p>
        capo_gamelift.errors.unsupported_region_exception.UnsupportedRegionException: <p>The requested operation is not supported in the Region specified.</p>
        capo_gamelift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_gamelift.types.create_container_group_definition_input.CreateContainerGroupDefinitionInput]",
    ) -> OperationResponse[
        "capo_gamelift.types.create_container_group_definition_output.CreateContainerGroupDefinitionOutput"
    ]:
        import capo_gamelift._operations.game_lift.create_container_group_definition

        output, http_response = (
            capo_gamelift._operations.game_lift.create_container_group_definition.create_container_group_definition(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_gamelift.types.create_container_group_definition_input.CreateContainerGroupDefinitionInput",
    ) -> dict[str, Any]:
        import capo_gamelift.types.create_container_group_definition_input

        return capo_gamelift.types.create_container_group_definition_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_gamelift.types.create_container_group_definition_output.CreateContainerGroupDefinitionOutput",
    ) -> dict[str, Any]:
        import capo_gamelift.types.create_container_group_definition_output

        return capo_gamelift.types.create_container_group_definition_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateContainerGroupDefinition",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_gamelift.types.create_container_group_definition_input.CreateContainerGroupDefinitionInput = {}
    if name is not None:
        input_["name"] = name
    if container_group_type is not None:
        input_["container_group_type"] = container_group_type
    if total_memory_limit_mebibytes is not None:
        input_["total_memory_limit_mebibytes"] = total_memory_limit_mebibytes
    if total_vcpu_limit is not None:
        input_["total_vcpu_limit"] = total_vcpu_limit
    if game_server_container_definition is not None:
        input_["game_server_container_definition"] = (
            game_server_container_definition
        )
    if support_container_definitions is not None:
        input_["support_container_definitions"] = support_container_definitions
    if operating_system is not None:
        input_["operating_system"] = operating_system
    if version_description is not None:
        input_["version_description"] = version_description
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output