Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
register-task-with-maintenance-windows 命令的参数选项
register-task-with-maintenance-window 命令提供多个选项用于根据您的需求配置任务。其中一些任务为必需,一些为可选,还有一些仅适用于单个维护时段任务类型。
本主题提供了有关其中一些选项的信息,以帮助您使用本教程这一部分中的示例。有关所有命令选项的信息,请参阅 Amazon CLI 命令参考中的 register-task-with-maintenance-window。
命令选项:--task-arn
--task-arn
选项用于指定执行任务的资源。您指定的值取决于所要注册的任务类型,如下表中所述。
维护时段任务的 TaskArn 格式
维护时段任务类型 |
TaskArn 值 |
RUN_COMMAND 和 AUTOMATION
|
TaskArn 是 SSM 文档名称或 Amazon Resource Name (ARN)。例如:
AWS-RunBatchShellScript
–或者–
arn:aws:ssm:region :111122223333:document/My-Document .
|
LAMBDA
|
TaskArn 是函数名称或 ARN。例如:
SSMMy-Lambda-Function
–或者–
arn:aws:lambda:region :111122223333:function:SSMMyLambdaFunction .
Maintenance Windows 的 IAM policy 要求您将前缀 SSM 添加到 Lambda 函数(或别名)名称。继续注册此类型的任务之前,请在 Amazon Lambda 中更新其名称,以包含 SSM 。例如,如果您的 Lambda 函数名称为 MyLambdaFunction ,请将其更改为 SSMMyLambdaFunction 。 |
STEP_FUNCTIONS
|
TaskArn 是状态机 ARN。例如:
arn:aws:states:us-east-2:111122223333:stateMachine:SSMMyStateMachine .
维护时段的 IAM policy 要求您使用 SSM 作为 Step Functions 状态机名称的前缀。您应先注册此类型的任务,然后必须在 Amazon Step Functions 中更新其名称以包含 SSM 。例如,如果您的状态机名为 MyStateMachine ,则将其更改为 SSMMyStateMachine 。
|
命令选项:--service-role-arn
运行维护时段任务时 Amazon Systems Manager 要代入的角色。
有关更多信息,请参阅设置 Maintenance Windows。
命令选项:--task-invocation-parameters
--task-invocation-parameters
选项用于指定分别对于四种任务类型唯一的参数。四种任务类型分别支持的参数如下表中所述。
有关在 --task-invocation-parameters
内容中使用伪参数的信息,例如 {{TARGET_ID}},请参阅注册维护时段任务时使用伪参数。
维护任务时段的任务调用参数选项
维护时段任务类型 |
可用参数 |
示例 |
RUN_COMMAND
|
Comment
DocumentHash
DocumentHashType
NotificationConfig
OutputS3BucketName
OutPutS3KeyPrefix
Parameters
ServiceRoleArn
TimeoutSeconds
|
"TaskInvocationParameters": {
"RunCommand": {
"Comment": "My Run Command task comment",
"DocumentHash": "6554ed3d--truncated--5EXAMPLE",
"DocumentHashType": "Sha256",
"NotificationConfig": {
"NotificationArn": "arn:aws:sns:region :123456789012:my-sns-topic-name",
"NotificationEvents": [
"FAILURE"
],
"NotificationType": "Invocation"
},
"OutputS3BucketName": "amzn-s3-demo-bucket",
"OutputS3KeyPrefix": "S3-PREFIX ",
"Parameters": {
"commands": [
"Get-ChildItem$env: temp-Recurse|Remove-Item-Recurse-force"
]
},
"ServiceRoleArn": "arn:aws:iam::123456789012:role/MyMaintenanceWindowServiceRole",
"TimeoutSeconds": 3600
}
}
|
AUTOMATION
|
DocumentVersion
Parameters
|
"TaskInvocationParameters": {
"Automation": {
"DocumentVersion": "3",
"Parameters": {
"instanceid": [
"{{TARGET_ID}}"
]
}
}
}
|
LAMBDA
|
ClientContext
Payload
Qualifier
|
"TaskInvocationParameters": {
"Lambda": {
"ClientContext": "ew0KICAi--truncated--0KIEXAMPLE",
"Payload": "{ \"targetId\": \"{{TARGET_ID}}\", \"targetType\": \"{{TARGET_TYPE}}\" }",
"Qualifier": "$LATEST"
}
}
|
STEP_FUNCTIONS
|
Input
Name
|
"TaskInvocationParameters": {
"StepFunctions": {
"Input": "{ \"targetId\": \"{{TARGET_ID}}\" }",
"Name": "{{INVOCATION_ID}}"
}
}
|