startChangeRequestExecution method

Future<StartChangeRequestExecutionResult> startChangeRequestExecution({
  1. required String documentName,
  2. required List<Runbook> runbooks,
  3. String? changeRequestName,
  4. String? clientToken,
  5. String? documentVersion,
  6. Map<String, List<String>>? parameters,
  7. DateTime? scheduledTime,
  8. List<Tag>? tags,
})

Creates a change request for Change Manager. The runbooks (Automation documents) specified in the change request run only after all required approvals for the change request have been received.

May throw AutomationDefinitionNotFoundException. May throw InvalidAutomationExecutionParametersException. May throw AutomationExecutionLimitExceededException. May throw AutomationDefinitionVersionNotFoundException. May throw IdempotentParameterMismatch. May throw InternalServerError. May throw AutomationDefinitionNotApprovedException.

Parameter documentName : The name of the change template document to run during the runbook workflow.

Parameter runbooks : Information about the Automation runbooks (Automation documents) that are run during the runbook workflow.

Parameter changeRequestName : The name of the change request associated with the runbook workflow to be run.

Parameter clientToken : The user-provided idempotency token. The token must be unique, is case insensitive, enforces the UUID format, and can't be reused.

Parameter documentVersion : The version of the change template document to run during the runbook workflow.

Parameter parameters : A key-value map of parameters that match the declared parameters in the change template document.

Parameter scheduledTime : The date and time specified in the change request to run the Automation runbooks.

Parameter tags : Optional metadata that you assign to a resource. You can specify a maximum of five tags for a change request. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag a change request to identify an environment or target AWS Region. In this case, you could specify the following key-value pairs:

  • Key=Environment,Value=Production
  • Key=Region,Value=us-east-2

Implementation

Future<StartChangeRequestExecutionResult> startChangeRequestExecution({
  required String documentName,
  required List<Runbook> runbooks,
  String? changeRequestName,
  String? clientToken,
  String? documentVersion,
  Map<String, List<String>>? parameters,
  DateTime? scheduledTime,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(documentName, 'documentName');
  ArgumentError.checkNotNull(runbooks, 'runbooks');
  _s.validateStringLength(
    'changeRequestName',
    changeRequestName,
    1,
    1024,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    36,
    36,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.StartChangeRequestExecution'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DocumentName': documentName,
      'Runbooks': runbooks,
      if (changeRequestName != null) 'ChangeRequestName': changeRequestName,
      if (clientToken != null) 'ClientToken': clientToken,
      if (documentVersion != null) 'DocumentVersion': documentVersion,
      if (parameters != null) 'Parameters': parameters,
      if (scheduledTime != null)
        'ScheduledTime': unixTimestampToJson(scheduledTime),
      if (tags != null) 'Tags': tags,
    },
  );

  return StartChangeRequestExecutionResult.fromJson(jsonResponse.body);
}