deleteGameServerGroup method

Future<DeleteGameServerGroupOutput> deleteGameServerGroup({
  1. required String gameServerGroupName,
  2. GameServerGroupDeleteOption? deleteOption,
})

This operation is used with the Amazon GameLift FleetIQ solution and game server groups.

Terminates a game server group and permanently deletes the game server group record. You have several options for how these resources are impacted when deleting the game server group. Depending on the type of delete operation selected, this operation might affect these resources:

  • The game server group
  • The corresponding Auto Scaling group
  • All game servers that are currently running in the group
To delete a game server group, identify the game server group to delete and specify the type of delete operation to initiate. Game server groups can only be deleted if they are in ACTIVE or ERROR status.

If the delete request is successful, a series of operations are kicked off. The game server group status is changed to DELETE_SCHEDULED, which prevents new game servers from being registered and stops automatic scaling activity. Once all game servers in the game server group are deregistered, GameLift FleetIQ can begin deleting resources. If any of the delete operations fail, the game server group is placed in ERROR status.

GameLift FleetIQ emits delete events to Amazon CloudWatch.

Learn more

GameLift FleetIQ Guide

Related operations

May throw InvalidRequestException. May throw NotFoundException. May throw UnauthorizedException. May throw InternalServiceException.

Parameter gameServerGroupName : A unique identifier for the game server group. Use either the GameServerGroup name or ARN value.

Parameter deleteOption : The type of delete to perform. Options include the following:

  • SAFE_DELETE – (default) Terminates the game server group and EC2 Auto Scaling group only when it has no game servers that are in UTILIZED status.
  • FORCE_DELETE – Terminates the game server group, including all active game servers regardless of their utilization status, and the EC2 Auto Scaling group.
  • RETAIN – Does a safe delete of the game server group but retains the EC2 Auto Scaling group as is.

Implementation

Future<DeleteGameServerGroupOutput> deleteGameServerGroup({
  required String gameServerGroupName,
  GameServerGroupDeleteOption? deleteOption,
}) async {
  ArgumentError.checkNotNull(gameServerGroupName, 'gameServerGroupName');
  _s.validateStringLength(
    'gameServerGroupName',
    gameServerGroupName,
    1,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.DeleteGameServerGroup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GameServerGroupName': gameServerGroupName,
      if (deleteOption != null) 'DeleteOption': deleteOption.toValue(),
    },
  );

  return DeleteGameServerGroupOutput.fromJson(jsonResponse.body);
}