简体   繁体   中英

SSMMaintenanceWindow unable to pass input parameter to AUTOMATION document using AWS powershell

I am trying to attach automation task with maintenancewindow using AWS powershell. I am trying to pass input parameters to the automation document. But its not working. When I see the document after attaching the input parameter value is empty. Not seeing any good documents also for the AUTOMATION type.

Something like this should work:

PS > $automationParameters = @{}
PS > $automationParameters.Add( "instanceId", @("{{ TARGET_ID }}") )
PS > $automationParameters.Add( "AutomationAssumeRole", @("arn:aws:iam
::111111111111:role/AutomationRole") )
PS > $automationParameters.Add( "SnapshotTimeout", @("PT20M") )
PS > Register-SSMTaskWithMaintenanceWindow -WindowId mw-123EXAMPLE456 -ServiceRoleArn "arn:aws:iam::123456789012:role/MW-Role" -MaxConcurrency 1 -MaxError 1 -TaskArn "CreateVolumeSnapshots" -Target @{ Key="WindowTargetIds";Values="4b5acdf4-946c-4355-bd68-4329a43a5fd1" } -TaskType "AUTOMATION" -Priority 4 -Automation_Docum
entVersion '$DEFAULT' -Automation_Parameter $automationParameters -Name "Create-Snapshots"

Note that I use the {{TARGET_ID}} syntax so the Automation task will run properly for each instance in the maintenance window target (see https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-mw-walk-cli.html for more details on this). Hope that helps.

You can find more information here: https://docs.aws.amazon.com/powershell/latest/reference/items/AWS_Systems_Manager_cmdlets.html

/Mats

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM