Skip to content

describe_container_group_port_mappings

describe_container_group_port_mappings(
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    fleet_id: Optional[FleetIdOrArn] = None,
    container_group_type: Optional[ContainerGroupType] = None,
    compute_name: Optional[ComputeNameOrArn] = None,
    instance_id: Optional[InstanceId] = None,
    container_name: Optional[ContainerNameQueryFilter] = None,
) -> DescribeContainerGroupPortMappingsOutput

This API works with the following fleet types: Container

Retrieves the port mappings for a container group running on a container fleet. Port mappings show how container ports are mapped to connection ports on the fleet instance. Use this operation to find the connection port for a specific container on a fleet instance.

Request options

  • Get port mappings for a game server container group. Provide the fleet ID, set ContainerGroupType to GAME_SERVER, and specify the ComputeName for the game server container group.

  • Get port mappings for a per-instance container group. Provide the fleet ID, set ContainerGroupType to PER_INSTANCE, and specify the InstanceId for the instance.

  • Optionally filter results to a single container by providing a ContainerName.

Results

This operation returns the fleet ID, fleet ARN, location, container group definition ARN, container group type, compute name (for game server container groups), instance ID, and a list of ContainerGroupPortMapping objects. Each object contains the container name, runtime ID, and a list of port mappings that show how container ports map to connection ports on the instance.

Learn more

Connect to containers

Create a container group definition

Parameters:

  • fleet_id (Optional[FleetIdOrArn], default: None ) –

    A unique identifier for the container fleet. You can use either the fleet ID or ARN value.

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

    The type of container group to retrieve port mappings for.

    • GAME_SERVER -- Get port mappings for a game server container group.

    • PER_INSTANCE -- Get port mappings for a per-instance container group.

  • compute_name (Optional[ComputeNameOrArn], default: None ) –

    A unique identifier for the compute resource for which to retrieve port mappings. For a container fleet, a compute represents a game server container group running on a fleet instance. You can use either the compute name or ARN value.

    When ContainerGroupType is GAME_SERVER, this parameter is required.

    When ContainerGroupType is PER_INSTANCE, do not provide this parameter. If you provide a compute name with PER_INSTANCE, the request fails with an InvalidRequestException.

  • instance_id (Optional[InstanceId], default: None ) –

    A unique identifier for the fleet instance to retrieve port mappings for.

    When ContainerGroupType is PER_INSTANCE, this parameter is required.

    When ContainerGroupType is GAME_SERVER, this parameter is optional. If you provide an instance ID, it must match the instance that's running the specified compute. If the instance ID doesn't match, the request fails with an InvalidRequestException.

  • container_name (Optional[ContainerNameQueryFilter], default: None ) –

    A container name to filter the results. When provided, the operation returns port mappings for the specified container only. If no container with the specified name exists in the container group, the request fails with a NotFoundException.

    If not provided, the operation returns port mappings for all containers in the container group.

Raises:

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

  • NotFoundException –

    The requested resource was not found. The resource was either not created yet or deleted.

  • 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 describe_container_group_port_mappings(
    self,
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    fleet_id: Optional["capo_gamelift.types.fleet_id_or_arn.FleetIdOrArn"] = None,
    container_group_type: Optional[
        "capo_gamelift.types.container_group_type.ContainerGroupType"
    ] = None,
    compute_name: Optional[
        "capo_gamelift.types.compute_name_or_arn.ComputeNameOrArn"
    ] = None,
    instance_id: Optional["capo_gamelift.types.instance_id.InstanceId"] = None,
    container_name: Optional[
        "capo_gamelift.types.container_name_query_filter.ContainerNameQueryFilter"
    ] = None,
) -> "capo_gamelift.types.describe_container_group_port_mappings_output.DescribeContainerGroupPortMappingsOutput":
    """<p> <b>This API works with the following fleet types:</b> Container</p> <p>Retrieves the port mappings for a container group running on a container fleet. Port mappings show how container ports are mapped to connection ports on the fleet instance. Use this operation to find the connection port for a specific container on a fleet instance.</p> <p> <b>Request options</b> </p> <ul> <li> <p>Get port mappings for a game server container group. Provide the fleet ID, set <code>ContainerGroupType</code> to <code>GAME_SERVER</code>, and specify the <code>ComputeName</code> for the game server container group.</p> </li> <li> <p>Get port mappings for a per-instance container group. Provide the fleet ID, set <code>ContainerGroupType</code> to <code>PER_INSTANCE</code>, and specify the <code>InstanceId</code> for the instance.</p> </li> <li> <p>Optionally filter results to a single container by providing a <code>ContainerName</code>.</p> </li> </ul> <p> <b>Results</b> </p> <p>This operation returns the fleet ID, fleet ARN, location, container group definition ARN, container group type, compute name (for game server container groups), instance ID, and a list of <code>ContainerGroupPortMapping</code> objects. Each object contains the container name, runtime ID, and a list of port mappings that show how container ports map to connection ports on the instance.</p> <p> <b>Learn more</b> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/containers-remote-access.html">Connect to containers</a> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/containers-create-groups.html">Create a container group definition</a> </p>

    Args:
        fleet_id: <p>A unique identifier for the container fleet. You can use either the fleet ID or ARN value.</p>
        container_group_type: <p>The type of container group to retrieve port mappings for.</p> <ul> <li> <p> <code>GAME_SERVER</code> -- Get port mappings for a game server container group.</p> </li> <li> <p> <code>PER_INSTANCE</code> -- Get port mappings for a per-instance container group.</p> </li> </ul>
        compute_name: <p>A unique identifier for the compute resource for which to retrieve port mappings. For a container fleet, a compute represents a game server container group running on a fleet instance. You can use either the compute name or ARN value.</p> <p>When <code>ContainerGroupType</code> is <code>GAME_SERVER</code>, this parameter is required.</p> <p>When <code>ContainerGroupType</code> is <code>PER_INSTANCE</code>, do not provide this parameter. If you provide a compute name with <code>PER_INSTANCE</code>, the request fails with an <code>InvalidRequestException</code>.</p>
        instance_id: <p>A unique identifier for the fleet instance to retrieve port mappings for.</p> <p>When <code>ContainerGroupType</code> is <code>PER_INSTANCE</code>, this parameter is required.</p> <p>When <code>ContainerGroupType</code> is <code>GAME_SERVER</code>, this parameter is optional. If you provide an instance ID, it must match the instance that's running the specified compute. If the instance ID doesn't match, the request fails with an <code>InvalidRequestException</code>.</p>
        container_name: <p>A container name to filter the results. When provided, the operation returns port mappings for the specified container only. If no container with the specified name exists in the container group, the request fails with a <code>NotFoundException</code>.</p> <p>If not provided, the operation returns port mappings for all containers in the container group.</p>

    Raises:
        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.not_found_exception.NotFoundException: <p>The requested resource was not found. The resource was either not created yet or deleted.</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.describe_container_group_port_mappings_input.DescribeContainerGroupPortMappingsInput]",
    ) -> OperationResponse[
        "capo_gamelift.types.describe_container_group_port_mappings_output.DescribeContainerGroupPortMappingsOutput"
    ]:
        import capo_gamelift._operations.game_lift.describe_container_group_port_mappings

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

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

        return capo_gamelift.types.describe_container_group_port_mappings_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "DescribeContainerGroupPortMappings", redact_output=_redact_output
        ),
    )
    input_: capo_gamelift.types.describe_container_group_port_mappings_input.DescribeContainerGroupPortMappingsInput = {}
    if fleet_id is not None:
        input_["fleet_id"] = fleet_id
    if container_group_type is not None:
        input_["container_group_type"] = container_group_type
    if compute_name is not None:
        input_["compute_name"] = compute_name
    if instance_id is not None:
        input_["instance_id"] = instance_id
    if container_name is not None:
        input_["container_name"] = container_name

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