updateStateMachine method

Future<UpdateStateMachineOutput> updateStateMachine({
  1. required String stateMachineArn,
  2. String? definition,
  3. EncryptionConfiguration? encryptionConfiguration,
  4. LoggingConfiguration? loggingConfiguration,
  5. bool? publish,
  6. String? roleArn,
  7. TracingConfiguration? tracingConfiguration,
  8. String? versionDescription,
})

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

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

    arn:

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

    arn:

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.

May throw ConflictException. May throw InvalidArn. May throw InvalidDefinition. May throw InvalidEncryptionConfiguration. May throw InvalidLoggingConfiguration. May throw InvalidTracingConfiguration. May throw KmsAccessDeniedException. May throw KmsThrottlingException. May throw MissingRequiredParameter. May throw ServiceQuotaExceededException. May throw StateMachineDeleting. May throw StateMachineDoesNotExist. May throw ValidationException.

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

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

Parameter encryptionConfiguration : Settings to configure server-side encryption.

Parameter loggingConfiguration : Use the LoggingConfiguration data type to set CloudWatch Logs options.

Parameter publish : 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.

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

Parameter tracingConfiguration : Selects whether X-Ray tracing is enabled.

Parameter versionDescription : An optional description of the state machine version to publish.

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

Implementation

Future<UpdateStateMachineOutput> updateStateMachine({
  required String stateMachineArn,
  String? definition,
  EncryptionConfiguration? encryptionConfiguration,
  LoggingConfiguration? loggingConfiguration,
  bool? publish,
  String? roleArn,
  TracingConfiguration? tracingConfiguration,
  String? versionDescription,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSStepFunctions.UpdateStateMachine'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'stateMachineArn': stateMachineArn,
      if (definition != null) 'definition': definition,
      if (encryptionConfiguration != null)
        'encryptionConfiguration': encryptionConfiguration,
      if (loggingConfiguration != null)
        'loggingConfiguration': loggingConfiguration,
      if (publish != null) 'publish': publish,
      if (roleArn != null) 'roleArn': roleArn,
      if (tracingConfiguration != null)
        'tracingConfiguration': tracingConfiguration,
      if (versionDescription != null)
        'versionDescription': versionDescription,
    },
  );

  return UpdateStateMachineOutput.fromJson(jsonResponse.body);
}