AWS-PatchAsgInstance - Amazon Systems Manager Automation runbook reference
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).



Patch Amazon Elastic Compute Cloud (Amazon EC2) instances in an Auto Scaling group.

Run this Automation (console)

Document type





Linux, macOS, Windows


  • AutomationAssumeRole

    Type: String

    Description: (Optional) The Amazon Resource Name (ARN) of the Amazon Identity and Access Management (IAM) role that allows Systems Manager Automation to perform the actions on your behalf. If no role is specified, Systems Manager Automation uses the permissions of the user that starts this runbook.

  • InstanceId

    Type: String

    Description: (Required) ID of the instance to patch. Don't specify an instance ID that is configured to run during a maintenance window.

  • LambdaRoleArn

    Type: String

    Description: (Optional) The ARN of the role that allows the Lambda created by Automation to perform the actions on your behalf. If not specified, a transient role will be created to run the Lambda function.

  • WaitForInstance

    Type: String

    Default: PT2M

    Description: (Optional) Duration that the Automation should sleep to allow the instance to come back into service.

  • WaitForReboot

    Type: String

    Default: PT5M

    Description: (Optional) Duration that the Automation should sleep to allow a patched instance to reboot.

Required IAM permissions

The AutomationAssumeRole parameter requires the following actions to use the runbook successfully.

  • ssm:StartAutomationExecution

  • ssm:GetAutomationExecution

  • ssm:GetCommandInvocation

  • ssm:GetParameter

  • ssm:SendCommand

  • cloudformation:CreateStack

  • cloudformation:DeleteStack

  • cloudformation:DescribeStacks

  • ec2:CreateTags

  • ec2:DescribeInstances

  • ec2:RunInstances

  • iam:AttachRolePolicy

  • iam:CreateRole

  • iam:DeleteRole

  • iam:DeleteRolePolicy

  • iam:DetachRolePolicy

  • iam:GetRole

  • iam:PassRole

  • iam:PutRolePolicy

  • lambda:CreateFunction

  • lambda:DeleteFunction

  • lambda:GetFunction

  • lambda:InvokeFunction