createAlias method

Future<CreateAliasOutput> createAlias({
  1. required String name,
  2. required RoutingStrategy routingStrategy,
  3. String? description,
  4. List<Tag>? tags,
})

Creates an alias for a fleet. In most situations, you can use an alias ID in place of a fleet ID. An alias provides a level of abstraction for a fleet that is useful when redirecting player traffic from one fleet to another, such as when updating your game build.

Amazon GameLift supports two types of routing strategies for aliases: simple and terminal. A simple alias points to an active fleet. A terminal alias is used to display messaging or link to a URL instead of routing players to an active fleet. For example, you might use a terminal alias when a game version is no longer supported and you want to direct players to an upgrade site.

To create a fleet alias, specify an alias name, routing strategy, and optional description. Each simple alias can point to only one fleet, but a fleet can have multiple aliases. If successful, a new alias record is returned, including an alias ID and an ARN. You can reassign an alias to another fleet by calling UpdateAlias.

May throw UnauthorizedException. May throw InvalidRequestException. May throw ConflictException. May throw InternalServiceException. May throw LimitExceededException. May throw TaggingFailedException.

Parameter name : A descriptive label that is associated with an alias. Alias names do not need to be unique.

Parameter routingStrategy : The routing configuration, including routing type and fleet target, for the alias.

Parameter description : A human-readable description of the alias.

Parameter tags : A list of labels to assign to the new alias 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. Once the resource is created, you can use TagResource, UntagResource, and ListTagsForResource to add, remove, and view tags. The maximum tag limit may be lower than stated. See the AWS General Reference for actual tagging limits.

Implementation

Future<CreateAliasOutput> createAlias({
  required String name,
  required RoutingStrategy routingStrategy,
  String? description,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(routingStrategy, 'routingStrategy');
  _s.validateStringLength(
    'description',
    description,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.CreateAlias'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'RoutingStrategy': routingStrategy,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateAliasOutput.fromJson(jsonResponse.body);
}