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:
Parameters:
-
description
(Optional[AliasDescription], default:
None
)
–
A description for the state machine alias.
-
name
(CharacterRestrictedName)
–
The name of the state machine alias.
To avoid conflict with version ARNs, don't use an integer in the name of the alias.
-
routing_configuration
(RoutingConfigurationList)
–
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.
Raises:
Source code in docs_src/capo_sfn/_services/sfn.py
| def create_state_machine_alias(
self,
name: "capo_sfn.types.character_restricted_name.CharacterRestrictedName",
routing_configuration: "capo_sfn.types.routing_configuration_list.RoutingConfigurationList",
*,
config_overrides: Optional[SFNClientConfig] = None,
description: Optional[
"capo_sfn.types.alias_description.AliasDescription"
] = None,
) -> (
"capo_sfn.types.create_state_machine_alias_output.CreateStateMachineAliasOutput"
):
"""<p>Creates an <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-alias.html">alias</a> for a state machine that points to one or two <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-version.html">versions</a> of the same state machine. You can set your application to call <a>StartExecution</a> with an alias and update the version the alias uses without changing the client's code.</p> <p>You can also map an alias to split <a>StartExecution</a> requests between two versions of a state machine. To do this, add a second <code>RoutingConfig</code> object in the <code>routingConfiguration</code> parameter. You must also specify the percentage of execution run requests each version should receive in both <code>RoutingConfig</code> objects. Step Functions randomly chooses which version runs a given execution based on the percentage you specify.</p> <p>To create an alias that points to a single version, specify a single <code>RoutingConfig</code> object with a <code>weight</code> set to 100.</p> <p>You can create up to 100 aliases for each state machine. You must delete unused aliases using the <a>DeleteStateMachineAlias</a> API action.</p> <p> <code>CreateStateMachineAlias</code> is an idempotent API. Step Functions bases the idempotency check on the <code>stateMachineArn</code>, <code>description</code>, <code>name</code>, and <code>routingConfiguration</code> parameters. Requests that contain the same values for these parameters return a successful idempotent response without creating a duplicate resource.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>DescribeStateMachineAlias</a> </p> </li> <li> <p> <a>ListStateMachineAliases</a> </p> </li> <li> <p> <a>UpdateStateMachineAlias</a> </p> </li> <li> <p> <a>DeleteStateMachineAlias</a> </p> </li> </ul>
Args:
description: <p>A description for the state machine alias.</p>
name: <p>The name of the state machine alias.</p> <p>To avoid conflict with version ARNs, don't use an integer in the name of the alias.</p>
routing_configuration: <p>The routing configuration of a state machine alias. The routing configuration shifts execution traffic between two state machine versions. <code>routingConfiguration</code> contains an array of <code>RoutingConfig</code> 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 <code>RoutingConfig</code>.</p>
Raises:
capo_sfn.errors.conflict_exception.ConflictException: <p>Updating or deleting a resource can cause an inconsistent state. This error occurs when there're concurrent requests for <a>DeleteStateMachineVersion</a>, <a>PublishStateMachineVersion</a>, or <a>UpdateStateMachine</a> with the <code>publish</code> parameter set to <code>true</code>.</p> <p>HTTP Status Code: 409</p>
capo_sfn.errors.invalid_arn.InvalidArn: <p>The provided Amazon Resource Name (ARN) is not valid.</p>
capo_sfn.errors.invalid_name.InvalidName: <p>The provided name is not valid.</p>
capo_sfn.errors.resource_not_found.ResourceNotFound: <p>Could not find the referenced resource.</p>
capo_sfn.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p> <p>HTTP Status Code: 402</p>
capo_sfn.errors.state_machine_deleting.StateMachineDeleting: <p>The specified state machine is being deleted.</p>
capo_sfn.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
capo_sfn.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_sfn.types.create_state_machine_alias_input.CreateStateMachineAliasInput]",
) -> OperationResponse[
"capo_sfn.types.create_state_machine_alias_output.CreateStateMachineAliasOutput"
]:
import capo_sfn._operations.aws_step_functions.create_state_machine_alias
output, http_response = (
capo_sfn._operations.aws_step_functions.create_state_machine_alias.create_state_machine_alias(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_sfn.types.create_state_machine_alias_input.CreateStateMachineAliasInput",
) -> dict[str, Any]:
import capo_sfn.types.create_state_machine_alias_input
return capo_sfn.types.create_state_machine_alias_input.redact_sensitive(
input_
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("CreateStateMachineAlias", redact_input=_redact_input),
)
input_: capo_sfn.types.create_state_machine_alias_input.CreateStateMachineAliasInput = {
"name": name,
"routing_configuration": routing_configuration,
}
if description is not None:
input_["description"] = description
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|