createAlias method

Future<AliasConfiguration> createAlias({
  1. required String functionName,
  2. required String functionVersion,
  3. required String name,
  4. String? description,
  5. AliasRoutingConfiguration? routingConfig,
})

Creates an alias for a Lambda function version. Use aliases to provide clients with a function identifier that you can update to invoke a different version.

You can also map an alias to split invocation requests between two versions. Use the RoutingConfig parameter to specify a second version and the percentage of invocation requests that it receives.

May throw ServiceException. May throw ResourceNotFoundException. May throw ResourceConflictException. May throw InvalidParameterValueException. May throw TooManyRequestsException.

Parameter functionName : The name of the Lambda function.

Name formats

  • Function name - MyFunction.
  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.
  • Partial ARN - 123456789012:function:MyFunction.
The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

Parameter functionVersion : The function version that the alias invokes.

Parameter name : The name of the alias.

Parameter description : A description of the alias.

Parameter routingConfig : The routing configuration of the alias.

Implementation

Future<AliasConfiguration> createAlias({
  required String functionName,
  required String functionVersion,
  required String name,
  String? description,
  AliasRoutingConfiguration? routingConfig,
}) async {
  ArgumentError.checkNotNull(functionName, 'functionName');
  _s.validateStringLength(
    'functionName',
    functionName,
    1,
    140,
    isRequired: true,
  );
  ArgumentError.checkNotNull(functionVersion, 'functionVersion');
  _s.validateStringLength(
    'functionVersion',
    functionVersion,
    1,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    256,
  );
  final $payload = <String, dynamic>{
    'FunctionVersion': functionVersion,
    'Name': name,
    if (description != null) 'Description': description,
    if (routingConfig != null) 'RoutingConfig': routingConfig,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/2015-03-31/functions/${Uri.encodeComponent(functionName)}/aliases',
    exceptionFnMap: _exceptionFns,
  );
  return AliasConfiguration.fromJson(response);
}