

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# `AWS-PatchAsgInstance`
<a name="automation-aws-patchasginstance"></a>

**Description**

在 Auto Scaling 群組中修補 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體。

[執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-PatchAsgInstance)

**重要**  
此 Runbook 會在執行期間將`AutoPatchInstanceInASG`標籤套用至目標執行個體。此標籤可防止 Runbook 在相同執行個體上同時執行兩次，這不是修補程式合規指標。如果修補步驟失敗，`Completed`即使 Runbook 執行狀態報告 ，標籤值仍可能設定為 `Failed`。  
若要驗證執行個體上的修補程式合規，請改用 [DescribeInstancePatchStates](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_DescribeInstancePatchStates.html) 或 [ListComplianceItems](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_ListComplianceItems.html)。

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 的使用者許可。
+ InstanceId

  類型：字串

  描述：(必要) 要修補的執行個體之 ID。請勿指定設定為在維護時段執行的執行個體 ID。
+ LambdaRoleArn

  類型：字串

  描述：（選用） 角色的 ARN，允許自動化建立的 Lambda 代表您執行動作。如果未指定，則會建立暫時性角色來執行 Lambda 函數。
+ WaitForInstance

  類型：字串

  預設：PT2M

  描述：（選用） 自動化應休眠的持續時間，以允許執行個體恢復服務。
+ WaitForReboot

  類型：字串

  預設：PT5M

  描述：（選用） 自動化應休眠的持續時間，以允許修補的執行個體重新啟動。

**必要的 IAM 許可**

`AutomationAssumeRole` 參數需要下列動作才能成功使用 Runbook。
+ `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`