updateMaintenanceWindowTask method
- required String windowId,
- required String windowTaskId,
- AlarmConfiguration? alarmConfiguration,
- MaintenanceWindowTaskCutoffBehavior? cutoffBehavior,
- String? description,
- LoggingInfo? loggingInfo,
- String? maxConcurrency,
- String? maxErrors,
- String? name,
- int? priority,
- bool? replace,
- String? serviceRoleArn,
- List<
Target> ? targets, - String? taskArn,
- MaintenanceWindowTaskInvocationParameters? taskInvocationParameters,
- Map<
String, MaintenanceWindowTaskParameterValueExpression> ? taskParameters,
Modifies a task assigned to a maintenance window. You can't change the task type, but you can change the following values:
-
TaskARN. For example, you can change aRUN_COMMANDtask fromAWS-RunPowerShellScripttoAWS-RunShellScript. -
ServiceRoleArn -
TaskInvocationParameters -
Priority -
MaxConcurrency -
MaxErrors
UpdateMaintenanceWindowTask
is null, then the corresponding field isn't modified. If you set
Replace to true, then all fields required by the
RegisterTaskWithMaintenanceWindow operation are required for this
request. Optional fields that aren't specified are set to null.
May throw DoesNotExistException.
May throw InternalServerError.
Parameter windowId :
The maintenance window ID that contains the task to modify.
Parameter windowTaskId :
The task ID to modify.
Parameter alarmConfiguration :
The CloudWatch alarm you want to apply to your maintenance window task.
Parameter cutoffBehavior :
Indicates whether tasks should continue to run after the cutoff time
specified in the maintenance windows is reached.
-
CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default value. -
CANCEL_TASK:- For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are already running continue, but no new task invocations are started.
- For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that attempts to cancel the command associated with the task. However, there is no guarantee that the command will be terminated and the underlying process stopped.
TIMED_OUT.
Parameter description :
The new task description to specify.
Parameter loggingInfo :
The new logging location in Amazon S3 to specify.
Parameter maxConcurrency :
The new MaxConcurrency value you want to specify.
MaxConcurrency is the number of targets that are allowed to
run this task, in parallel.
For maintenance window tasks without a target specified, you can't supply
a value for this option. Instead, the system inserts a placeholder value
of 1. This value doesn't affect the running of your task.
Parameter maxErrors :
The new MaxErrors value to specify. MaxErrors is
the maximum number of errors that are allowed before the task stops being
scheduled.
For maintenance window tasks without a target specified, you can't supply
a value for this option. Instead, the system inserts a placeholder value
of 1. This value doesn't affect the running of your task.
Parameter name :
The new task name to specify.
Parameter priority :
The new task priority to specify. The lower the number, the higher the
priority. Tasks that have the same priority are scheduled in parallel.
Parameter replace :
If True, then all fields that are required by the
RegisterTaskWithMaintenanceWindow operation are also required for
this API request. Optional fields that aren't specified are set to null.
Parameter serviceRoleArn :
The Amazon Resource Name (ARN) of the IAM service role for Amazon Web
Services Systems Manager to assume when running a maintenance window task.
If you do not specify a service role ARN, Systems Manager uses a
service-linked role in your account. If no appropriate service-linked role
for Systems Manager exists in your account, it is created when you run
RegisterTaskWithMaintenanceWindow.
However, for an improved security posture, we strongly recommend creating a custom policy and custom service role for running your maintenance window tasks. The policy can be crafted to provide only the permissions needed for your particular maintenance window tasks. For more information, see Setting up Maintenance Windows in the in the Amazon Web Services Systems Manager User Guide.
Parameter targets :
The targets (either managed nodes or tags) to modify. Managed nodes are
specified using the format
Key=instanceids,Values=instanceID_1,instanceID_2. Tags are
specified using the format Key=tag_name,Values=tag_value.
Parameter taskArn :
The task ARN to modify.
Parameter taskInvocationParameters :
The parameters that the task should use during execution. Populate only
the fields that match the task type. All other fields should be empty.
Parameter taskParameters :
The parameters to modify.
The map has the following format:
Key: string, between 1 and 255 characters
Value: an array of strings, each string is between 1 and 255 characters
Implementation
Future<UpdateMaintenanceWindowTaskResult> updateMaintenanceWindowTask({
required String windowId,
required String windowTaskId,
AlarmConfiguration? alarmConfiguration,
MaintenanceWindowTaskCutoffBehavior? cutoffBehavior,
String? description,
LoggingInfo? loggingInfo,
String? maxConcurrency,
String? maxErrors,
String? name,
int? priority,
bool? replace,
String? serviceRoleArn,
List<Target>? targets,
String? taskArn,
MaintenanceWindowTaskInvocationParameters? taskInvocationParameters,
Map<String, MaintenanceWindowTaskParameterValueExpression>? taskParameters,
}) async {
_s.validateNumRange(
'priority',
priority,
0,
1152921504606846976,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonSSM.UpdateMaintenanceWindowTask'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'WindowId': windowId,
'WindowTaskId': windowTaskId,
if (alarmConfiguration != null)
'AlarmConfiguration': alarmConfiguration,
if (cutoffBehavior != null) 'CutoffBehavior': cutoffBehavior.value,
if (description != null) 'Description': description,
if (loggingInfo != null) 'LoggingInfo': loggingInfo,
if (maxConcurrency != null) 'MaxConcurrency': maxConcurrency,
if (maxErrors != null) 'MaxErrors': maxErrors,
if (name != null) 'Name': name,
if (priority != null) 'Priority': priority,
if (replace != null) 'Replace': replace,
if (serviceRoleArn != null) 'ServiceRoleArn': serviceRoleArn,
if (targets != null) 'Targets': targets,
if (taskArn != null) 'TaskArn': taskArn,
if (taskInvocationParameters != null)
'TaskInvocationParameters': taskInvocationParameters,
if (taskParameters != null) 'TaskParameters': taskParameters,
},
);
return UpdateMaintenanceWindowTaskResult.fromJson(jsonResponse.body);
}