Skip to content

update_state_machine

update_state_machine(
    state_machine_arn: Arn,
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    definition: Optional[Definition] = None,
    role_arn: Optional[Arn] = None,
    logging_configuration: Optional[LoggingConfiguration] = None,
    tracing_configuration: Optional[TracingConfiguration] = None,
    publish: Optional[Publish] = None,
    version_description: Optional[VersionDescription] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
) -> UpdateStateMachineOutput

Updates an existing state machine by modifying its definition, roleArn, loggingConfiguration, or EncryptionConfiguration. Running executions will continue to use the previous definition and roleArn. You must include at least one of definition or roleArn or you will receive a MissingRequiredParameter error.

A qualified state machine ARN refers to a Distributed Map state defined within a state machine. For example, the qualified state machine ARN arn:partition:states:region:account-id:stateMachine:stateMachineName/mapStateLabel refers to a Distributed Map state with a label mapStateLabel in the state machine named stateMachineName.

A qualified state machine ARN can either refer to a Distributed Map state defined within a state machine, a version ARN, or an alias ARN.

The following are some examples of qualified and unqualified state machine ARNs:

  • The following qualified state machine ARN refers to a Distributed Map state with a label mapStateLabel in a state machine named myStateMachine.

    arn:partition:states:region:account-id:stateMachine:myStateMachine/mapStateLabel

    If you provide a qualified state machine ARN that refers to a Distributed Map state, the request fails with ValidationException.

  • The following qualified state machine ARN refers to an alias named PROD.

    arn::states:::stateMachine:

    If you provide a qualified state machine ARN that refers to a version ARN or an alias ARN, the request starts execution for that version or alias.

  • The following unqualified state machine ARN refers to a state machine named myStateMachine.

    arn::states:::stateMachine:

After you update your state machine, you can set the publish parameter to true in the same action to publish a new version. This way, you can opt-in to strict versioning of your state machine.

Step Functions assigns monotonically increasing integers for state machine versions, starting at version number 1.

All StartExecution calls within a few seconds use the updated definition and roleArn. Executions started immediately after you call UpdateStateMachine may use the previous state machine definition and roleArn.

Parameters:

  • state_machine_arn (Arn) –

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

  • definition (Optional[Definition], default: None ) –

    The Amazon States Language definition of the state machine. See Amazon States Language.

  • role_arn (Optional[Arn], default: None ) –

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

  • logging_configuration (Optional[LoggingConfiguration], default: None ) –

    Use the LoggingConfiguration data type to set CloudWatch Logs options.

  • tracing_configuration (Optional[TracingConfiguration], default: None ) –

    Selects whether X-Ray tracing is enabled.

  • publish (Optional[Publish], default: None ) –

    Specifies whether the state machine version is published. The default is false. To publish a version after updating the state machine, set publish to true.

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

    An optional description of the state machine version to publish.

    You can only specify the versionDescription parameter if you've set publish to true.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    Settings to configure server-side encryption.

Raises:

Source code in docs_src/capo_sfn/_services/sfn.py
def update_state_machine(
    self,
    state_machine_arn: "capo_sfn.types.arn.Arn",
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    definition: Optional["capo_sfn.types.definition.Definition"] = None,
    role_arn: Optional["capo_sfn.types.arn.Arn"] = None,
    logging_configuration: Optional[
        "capo_sfn.types.logging_configuration.LoggingConfiguration"
    ] = None,
    tracing_configuration: Optional[
        "capo_sfn.types.tracing_configuration.TracingConfiguration"
    ] = None,
    publish: Optional["capo_sfn.types.publish.Publish"] = None,
    version_description: Optional[
        "capo_sfn.types.version_description.VersionDescription"
    ] = None,
    encryption_configuration: Optional[
        "capo_sfn.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
) -> "capo_sfn.types.update_state_machine_output.UpdateStateMachineOutput":
    """<p>Updates an existing state machine by modifying its <code>definition</code>, <code>roleArn</code>, <code>loggingConfiguration</code>, or <code>EncryptionConfiguration</code>. Running executions will continue to use the previous <code>definition</code> and <code>roleArn</code>. You must include at least one of <code>definition</code> or <code>roleArn</code> or you will receive a <code>MissingRequiredParameter</code> error.</p> <p>A qualified state machine ARN refers to a <i>Distributed Map state</i> defined within a state machine. For example, the qualified state machine ARN <code>arn:partition:states:region:account-id:stateMachine:stateMachineName/mapStateLabel</code> refers to a <i>Distributed Map state</i> with a label <code>mapStateLabel</code> in the state machine named <code>stateMachineName</code>.</p> <p>A qualified state machine ARN can either refer to a <i>Distributed Map state</i> defined within a state machine, a version ARN, or an alias ARN.</p> <p>The following are some examples of qualified and unqualified state machine ARNs:</p> <ul> <li> <p>The following qualified state machine ARN refers to a <i>Distributed Map state</i> with a label <code>mapStateLabel</code> in a state machine named <code>myStateMachine</code>.</p> <p> <code>arn:partition:states:region:account-id:stateMachine:myStateMachine/mapStateLabel</code> </p> <note> <p>If you provide a qualified state machine ARN that refers to a <i>Distributed Map state</i>, the request fails with <code>ValidationException</code>.</p> </note> </li> <li> <p>The following qualified state machine ARN refers to an alias named <code>PROD</code>.</p> <p> <code>arn:<partition>:states:<region>:<account-id>:stateMachine:<myStateMachine:PROD></code> </p> <note> <p>If you provide a qualified state machine ARN that refers to a version ARN or an alias ARN, the request starts execution for that version or alias.</p> </note> </li> <li> <p>The following unqualified state machine ARN refers to a state machine named <code>myStateMachine</code>.</p> <p> <code>arn:<partition>:states:<region>:<account-id>:stateMachine:<myStateMachine></code> </p> </li> </ul> <p>After you update your state machine, you can set the <code>publish</code> parameter to <code>true</code> in the same action to publish a new <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-version.html">version</a>. This way, you can opt-in to strict versioning of your state machine.</p> <note> <p>Step Functions assigns monotonically increasing integers for state machine versions, starting at version number 1.</p> </note> <note> <p>All <code>StartExecution</code> calls within a few seconds use the updated <code>definition</code> and <code>roleArn</code>. Executions started immediately after you call <code>UpdateStateMachine</code> may use the previous state machine <code>definition</code> and <code>roleArn</code>. </p> </note>

    Args:
        state_machine_arn: <p>The Amazon Resource Name (ARN) of the state machine.</p>
        definition: <p>The Amazon States Language definition of the state machine. See <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a>.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role of the state machine.</p>
        logging_configuration: <p>Use the <code>LoggingConfiguration</code> data type to set CloudWatch Logs options.</p>
        tracing_configuration: <p>Selects whether X-Ray tracing is enabled.</p>
        publish: <p>Specifies whether the state machine version is published. The default is <code>false</code>. To publish a version after updating the state machine, set <code>publish</code> to <code>true</code>.</p>
        version_description: <p>An optional description of the state machine version to publish.</p> <p>You can only specify the <code>versionDescription</code> parameter if you've set <code>publish</code> to <code>true</code>.</p>
        encryption_configuration: <p>Settings to configure server-side encryption. </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_definition.InvalidDefinition: <p>The provided Amazon States Language definition is not valid.</p>
        capo_sfn.errors.invalid_encryption_configuration.InvalidEncryptionConfiguration: <p>Received when <code>encryptionConfiguration</code> is specified but various conditions exist which make the configuration invalid. For example, if <code>type</code> is set to <code>CUSTOMER_MANAGED_KMS_KEY</code>, but <code>kmsKeyId</code> is null, or <code>kmsDataKeyReusePeriodSeconds</code> is not between 60 and 900, or the KMS key is not symmetric or inactive.</p>
        capo_sfn.errors.invalid_logging_configuration.InvalidLoggingConfiguration: <p>Configuration is not valid.</p>
        capo_sfn.errors.invalid_tracing_configuration.InvalidTracingConfiguration: <p>Your <code>tracingConfiguration</code> key does not match, or <code>enabled</code> has not been set to <code>true</code> or <code>false</code>.</p>
        capo_sfn.errors.kms_access_denied_exception.KmsAccessDeniedException: <p>Either your KMS key policy or API caller does not have the required permissions.</p>
        capo_sfn.errors.kms_throttling_exception.KmsThrottlingException: <p>Received when KMS returns <code>ThrottlingException</code> for a KMS call that Step Functions makes on behalf of the caller.</p>
        capo_sfn.errors.missing_required_parameter.MissingRequiredParameter: <p>Request is missing a required parameter. This error occurs if both <code>definition</code> and <code>roleArn</code> are not specified.</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.
    """

    def _handler(
        req: "OperationRequest[capo_sfn.types.update_state_machine_input.UpdateStateMachineInput]",
    ) -> OperationResponse[
        "capo_sfn.types.update_state_machine_output.UpdateStateMachineOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.update_state_machine

        output, http_response = (
            capo_sfn._operations.aws_step_functions.update_state_machine.update_state_machine(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

        return capo_sfn.types.update_state_machine_input.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("UpdateStateMachine", redact_input=_redact_input),
    )
    input_: capo_sfn.types.update_state_machine_input.UpdateStateMachineInput = {
        "state_machine_arn": state_machine_arn
    }
    if definition is not None:
        input_["definition"] = definition
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if logging_configuration is not None:
        input_["logging_configuration"] = logging_configuration
    if tracing_configuration is not None:
        input_["tracing_configuration"] = tracing_configuration
    if publish is not None:
        input_["publish"] = publish
    if version_description is not None:
        input_["version_description"] = version_description
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output