createStateMachineAlias method

Future<CreateStateMachineAliasOutput> createStateMachineAlias({
  1. required String name,
  2. required List<RoutingConfigurationListItem> routingConfiguration,
  3. String? description,
})

Creates an alias for a state machine that points to one or two versions of the same state machine. You can set your application to call StartExecution with an alias and update the version the alias uses without changing the client's code.

You can also map an alias to split StartExecution requests between two versions of a state machine. To do this, add a second RoutingConfig object in the routingConfiguration parameter. You must also specify the percentage of execution run requests each version should receive in both RoutingConfig objects. Step Functions randomly chooses which version runs a given execution based on the percentage you specify.

To create an alias that points to a single version, specify a single RoutingConfig object with a weight set to 100.

You can create up to 100 aliases for each state machine. You must delete unused aliases using the DeleteStateMachineAlias API action.

CreateStateMachineAlias is an idempotent API. Step Functions bases the idempotency check on the stateMachineArn, description, name, and routingConfiguration parameters. Requests that contain the same values for these parameters return a successful idempotent response without creating a duplicate resource.

Related operations:

May throw ConflictException. May throw InvalidArn. May throw InvalidName. May throw ResourceNotFound. May throw ServiceQuotaExceededException. May throw StateMachineDeleting. May throw ValidationException.

Parameter name : The name of the state machine alias.

To avoid conflict with version ARNs, don't use an integer in the name of the alias.

Parameter routingConfiguration : The routing configuration of a state machine alias. The routing configuration shifts execution traffic between two state machine versions. routingConfiguration contains an array of RoutingConfig objects that specify up to two state machine versions. Step Functions then randomly choses which version to run an execution with based on the weight assigned to each RoutingConfig.

Parameter description : A description for the state machine alias.

Implementation

Future<CreateStateMachineAliasOutput> createStateMachineAlias({
  required String name,
  required List<RoutingConfigurationListItem> routingConfiguration,
  String? description,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSStepFunctions.CreateStateMachineAlias'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'name': name,
      'routingConfiguration': routingConfiguration,
      if (description != null) 'description': description,
    },
  );

  return CreateStateMachineAliasOutput.fromJson(jsonResponse.body);
}