Skip to content

publish_state_machine_version async

publish_state_machine_version(
    state_machine_arn: Arn,
    *,
    config_overrides: Optional[AsyncSFNClientConfig] = None,
    revision_id: Optional[RevisionId] = None,
    description: Optional[VersionDescription] = None,
) -> PublishStateMachineVersionOutput

Creates a version from the current revision of a state machine. Use versions to create immutable snapshots of your state machine. You can start executions from versions either directly or with an alias. To create an alias, use CreateStateMachineAlias.

You can publish up to 1000 versions for each state machine. You must manually delete unused versions using the DeleteStateMachineVersion API action.

PublishStateMachineVersion is an idempotent API. It doesn't create a duplicate state machine version if it already exists for the current revision. Step Functions bases PublishStateMachineVersion's idempotency check on the stateMachineArn, name, and revisionId parameters. Requests with the same parameters return a successful idempotent response. If you don't specify a revisionId, Step Functions checks for a previously published version of the state machine's current revision.

Related operations:

Parameters:

  • state_machine_arn (Arn) –

    The Amazon Resource Name (ARN) of the state machine.

  • revision_id (Optional[RevisionId], default: None ) –

    Only publish the state machine version if the current state machine's revision ID matches the specified ID.

    Use this option to avoid publishing a version if the state machine changed since you last updated it. If the specified revision ID doesn't match the state machine's current revision ID, the API returns ConflictException.

    To specify an initial revision ID for a state machine with no revision ID assigned, specify the string INITIAL for the revisionId parameter. For example, you can specify a revisionID of INITIAL when you create a state machine using the CreateStateMachine API action.

  • description (Optional[VersionDescription], default: None ) –

    An optional description of the state machine version.

Raises:

Source code in docs_src/capo_sfn/_services/async_sfn.py
async def publish_state_machine_version(
    self,
    state_machine_arn: "capo_sfn.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncSFNClientConfig] = None,
    revision_id: Optional["capo_sfn.types.revision_id.RevisionId"] = None,
    description: Optional[
        "capo_sfn.types.version_description.VersionDescription"
    ] = None,
) -> "capo_sfn.types.publish_state_machine_version_output.PublishStateMachineVersionOutput":
    """<p>Creates a <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-version.html">version</a> from the current revision of a state machine. Use versions to create immutable snapshots of your state machine. You can start executions from versions either directly or with an alias. To create an alias, use <a>CreateStateMachineAlias</a>.</p> <p>You can publish up to 1000 versions for each state machine. You must manually delete unused versions using the <a>DeleteStateMachineVersion</a> API action.</p> <p> <code>PublishStateMachineVersion</code> is an idempotent API. It doesn't create a duplicate state machine version if it already exists for the current revision. Step Functions bases <code>PublishStateMachineVersion</code>'s idempotency check on the <code>stateMachineArn</code>, <code>name</code>, and <code>revisionId</code> parameters. Requests with the same parameters return a successful idempotent response. If you don't specify a <code>revisionId</code>, Step Functions checks for a previously published version of the state machine's current revision.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>DeleteStateMachineVersion</a> </p> </li> <li> <p> <a>ListStateMachineVersions</a> </p> </li> </ul>

    Args:
        state_machine_arn: <p>The Amazon Resource Name (ARN) of the state machine.</p>
        revision_id: <p>Only publish the state machine version if the current state machine's revision ID matches the specified ID.</p> <p>Use this option to avoid publishing a version if the state machine changed since you last updated it. If the specified revision ID doesn't match the state machine's current revision ID, the API returns <code>ConflictException</code>.</p> <note> <p>To specify an initial revision ID for a state machine with no revision ID assigned, specify the string <code>INITIAL</code> for the <code>revisionId</code> parameter. For example, you can specify a <code>revisionID</code> of <code>INITIAL</code> when you create a state machine using the <a>CreateStateMachine</a> API action.</p> </note>
        description: <p>An optional description of the state machine version.</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.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.state_machine_does_not_exist.StateMachineDoesNotExist: <p>The specified state machine does not exist.</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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sfn.types.publish_state_machine_version_input.PublishStateMachineVersionInput]",
    ) -> AsyncOperationResponse[
        "capo_sfn.types.publish_state_machine_version_output.PublishStateMachineVersionOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.publish_state_machine_version

        (
            output,
            http_response,
        ) = await capo_sfn._operations.aws_step_functions.publish_state_machine_version.async_publish_state_machine_version(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sfn.types.publish_state_machine_version_input.PublishStateMachineVersionInput",
    ) -> dict[str, Any]:
        import capo_sfn.types.publish_state_machine_version_input

        return capo_sfn.types.publish_state_machine_version_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PublishStateMachineVersion", redact_input=_redact_input),
    )
    input_: capo_sfn.types.publish_state_machine_version_input.PublishStateMachineVersionInput = {
        "state_machine_arn": state_machine_arn
    }
    if revision_id is not None:
        input_["revision_id"] = revision_id
    if description is not None:
        input_["description"] = description

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output