Question: How do I add parameters when registering an Automation task with Systems Manager maintenance windows?

I want to register an Automation document task for an AWS Systems Manager maintenance window that targets multiple Amazon Elastic Compute Cloud (Amazon EC2) instances. How can I do that?Short descriptionWhen you register a maintenance window Automation task, you must provide input parameter values that pass to the task when the task runs. The required input parameters are the same as the parameters defined in the Automation document content. You can use pseudo parameter values in the required input parameter fields to dynamically reference the resource IDs that the maintenance window targets. Pseudo parameters, such as {{RESOURCE_ID}}, allow you to target multiple resources without entering each resource ID individually.For example, the Amazon-provided AWS-StopEC2Instance document requires that you enter the instance ID as a parameter. If you want the maintenance window to target multiple instances, or if you don’t know the instance ID, you can use a pseudo parameter.Note: For target type INSTANCE, both the {{TARGET_ID}} and {{RESOURCE_ID}} pseudo parameters yield only the instance ID. However, for target type RESOURCE_GROUP, {{TARGET_ID}} and {{RESOURCE_ID}} return the ID in different formats. For more information, and for a list of available pseudo parameters, see About pseudo parameters.You can use either the Systems Manager console or the AWS Command Line Interface (AWS CLI) to register maintenance window Automation tasks with pseudo parameters.

ResolutionUsing the consoleTo register a maintenance window Automation task using dynamic pseudo parameters, follow these steps:Open the Systems Manager console, and then choose Maintenance Windows from the navigation pane.Select your maintenance window, and then choose View details.From the Tasks tab, choose Register tasks, Register Automation task.For Automation document, select the document that you want the task to run.Specify your Targets, Rate control, and IAM service role.For Input parameters, enter a pseudo parameter value (for example, {{TARGET_ID}} or {{RESOURCE_ID}}) for the parameter that requires a resource ID.Choose Register Automation task.Using the AWS CLINote: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.The following example uses the AWS CLI to register an Automation task including the {{RESOURCE_ID}} parameter:aws ssm register-task-with-maintenance-window --window-id mw-1234567890EXAMPLE --targets Key=WindowTargetIds,Values=6c226ea3-463a-4533-8a2d-EXAMPLE --task-arn AWS-StopEC2Instance --task-type AUTOMATION --name MyMaintenanceWindowTask --max-concurrency 10 --max-errors 5 --task-invocation-parameters={\"Automation\":{\"Parameters\":{\"InstanceId\":[\"{{RESOURCE_ID}}\"]}}} --service-role-arn YOUR_SERVICE_ROLE_ARNWhen the maintenance window task runs, the corresponding Resource ID for each target passes to the system. In the preceding example, the InstanceId parameter receives the corresponding instance ID for each target in the target group.

Related informationSupported pseudo parametersAbout register-task-with-maintenance-windows options