registerTargetWithMaintenanceWindow method
Registers a target with a maintenance window.
May throw IdempotentParameterMismatch. May throw DoesNotExistException. May throw ResourceLimitExceededException. May throw InternalServerError.
Parameter resourceType
:
The type of target being registered with the maintenance window.
Parameter targets
:
The targets to register with the maintenance window. In other words, the
instances to run commands on when the maintenance window runs.
You can specify targets using instance IDs, resource group names, or tags that have been applied to instances.
Example 1: Specify instance IDs
Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3
Example 2: Use tag key-pairs applied to instances
Key=tag:my-tag-key,Values=my-tag-value-1,my-tag-value-2
Example 3: Use tag-keys applied to instances
Key=tag-key,Values=my-tag-key-1,my-tag-key-2
Example 4: Use resource group names
Key=resource-groups:Name,Values=resource-group-name
Example 5: Use filters for resource group types
Key=resource-groups:ResourceTypeFilters,Values=resource-type-1,resource-type-2
Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC
For more information about these examples formats, including the best use
case for each one, see Examples:
Register targets with a maintenance window in the AWS Systems
Manager User Guide.
Parameter windowId
:
The ID of the maintenance window the target should be registered with.
Parameter clientToken
:
User-provided idempotency token.
Parameter description
:
An optional description for the target.
Parameter name
:
An optional name for the target.
Parameter ownerInformation
:
User-provided value that will be included in any CloudWatch events raised
while running tasks for these targets in this maintenance window.
Implementation
Future<RegisterTargetWithMaintenanceWindowResult>
registerTargetWithMaintenanceWindow({
required MaintenanceWindowResourceType resourceType,
required List<Target> targets,
required String windowId,
String? clientToken,
String? description,
String? name,
String? ownerInformation,
}) async {
ArgumentError.checkNotNull(resourceType, 'resourceType');
ArgumentError.checkNotNull(targets, 'targets');
ArgumentError.checkNotNull(windowId, 'windowId');
_s.validateStringLength(
'windowId',
windowId,
20,
20,
isRequired: true,
);
_s.validateStringLength(
'clientToken',
clientToken,
1,
64,
);
_s.validateStringLength(
'description',
description,
1,
128,
);
_s.validateStringLength(
'name',
name,
3,
128,
);
_s.validateStringLength(
'ownerInformation',
ownerInformation,
1,
128,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonSSM.RegisterTargetWithMaintenanceWindow'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'ResourceType': resourceType.toValue(),
'Targets': targets,
'WindowId': windowId,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (description != null) 'Description': description,
if (name != null) 'Name': name,
if (ownerInformation != null) 'OwnerInformation': ownerInformation,
},
);
return RegisterTargetWithMaintenanceWindowResult.fromJson(
jsonResponse.body);
}