-
執行下列命令以建立名為 Production-Baseline
的 Windows 修補基準。此修補基準會在修補程式發行或最後更新 7 天後核准生產環境的修補程式。也就是說,我們已標記修補基準,以表示其用於生產環境。
- Linux & macOS
-
aws ssm create-patch-baseline \
--name "Production-Baseline" \
--operating-system "WINDOWS" \
--tags "Key=Environment,Value=Production" \
--approval-rules "PatchRules=[{PatchFilterGroup={PatchFilters=[{Key=MSRC_SEVERITY,Values=[Critical,Important]},{Key=CLASSIFICATION,Values=[SecurityUpdates,Updates,ServicePacks,UpdateRollups,CriticalUpdates]}]},ApproveAfterDays=7}]" \
--description "Baseline containing all updates approved for production systems"
- Windows Server
-
aws ssm create-patch-baseline ^
--name "Production-Baseline" ^
--operating-system "WINDOWS" ^
--tags "Key=Environment,Value=Production" ^
--approval-rules "PatchRules=[{PatchFilterGroup={PatchFilters=[{Key=MSRC_SEVERITY,Values=[Critical,Important]},{Key=CLASSIFICATION,Values=[SecurityUpdates,Updates,ServicePacks,UpdateRollups,CriticalUpdates]}]},ApproveAfterDays=7}]" ^
--description "Baseline containing all updates approved for production systems"
系統會傳回相關資訊,如下所示。
{
"BaselineId":"pb-0c10e65780EXAMPLE"
}
-
執行下列命令,以註冊兩個修補程式群組的「Production-Baseline」修補基準。群組命名為「資料庫伺服器」和「前端伺服器」。
- Linux & macOS
-
aws ssm register-patch-baseline-for-patch-group \
--baseline-id pb-0c10e65780EXAMPLE \
--patch-group "Database Servers"
- Windows Server
-
aws ssm register-patch-baseline-for-patch-group ^
--baseline-id pb-0c10e65780EXAMPLE ^
--patch-group "Database Servers"
系統會傳回相關資訊,如下所示。
{
"PatchGroup":"Database Servers",
"BaselineId":"pb-0c10e65780EXAMPLE"
}
- Linux & macOS
-
aws ssm register-patch-baseline-for-patch-group \
--baseline-id pb-0c10e65780EXAMPLE \
--patch-group "Front-End Servers"
- Windows Server
-
aws ssm register-patch-baseline-for-patch-group ^
--baseline-id pb-0c10e65780EXAMPLE ^
--patch-group "Front-End Servers"
系統會傳回相關資訊,如下所示。
{
"PatchGroup":"Front-End Servers",
"BaselineId":"pb-0c10e65780EXAMPLE"
}
-
執行以下命令來為生產伺服器建立兩個維護時段。第一個時段為每個星期二的晚上 10 點。第二個時段為每個星期六的晚上 10 點。此外,維護時段已加上標籤,表示其用於生產環境。
- Linux & macOS
-
aws ssm create-maintenance-window \
--name "Production-Tuesdays" \
--tags "Key=Environment,Value=Production" \
--schedule "cron(0 0 22 ? * TUE *)" \
--duration 1 \
--cutoff 0 \
--no-allow-unassociated-targets
- Windows Server
-
aws ssm create-maintenance-window ^
--name "Production-Tuesdays" ^
--tags "Key=Environment,Value=Production" ^
--schedule "cron(0 0 22 ? * TUE *)" ^
--duration 1 ^
--cutoff 0 ^
--no-allow-unassociated-targets
系統會傳回相關資訊,如下所示。
{
"WindowId":"mw-0c50858d01EXAMPLE"
}
- Linux & macOS
-
aws ssm create-maintenance-window \
--name "Production-Saturdays" \
--tags "Key=Environment,Value=Production" \
--schedule "cron(0 0 22 ? * SAT *)" \
--duration 2 \
--cutoff 0 \
--no-allow-unassociated-targets
- Windows Server
-
aws ssm create-maintenance-window ^
--name "Production-Saturdays" ^
--tags "Key=Environment,Value=Production" ^
--schedule "cron(0 0 22 ? * SAT *)" ^
--duration 2 ^
--cutoff 0 ^
--no-allow-unassociated-targets
系統會傳回相關資訊,如下所示。
{
"WindowId":"mw-9a8b7c6d5eEXAMPLE"
}
-
執行下列命令,將 Database
和 Front-End
伺服器修補程式群組註冊到各自的維護時段。
- Linux & macOS
-
aws ssm register-target-with-maintenance-window \
--window-id mw-0c50858d01EXAMPLE \
--targets "Key=tag:PatchGroup,Values=Database Servers" \
--owner-information "Database Servers" \
--resource-type "INSTANCE"
- Windows Server
-
aws ssm register-target-with-maintenance-window ^
--window-id mw-0c50858d01EXAMPLE ^
--targets "Key=tag:PatchGroup,Values=Database Servers" ^
--owner-information "Database Servers" ^
--resource-type "INSTANCE"
系統會傳回相關資訊,如下所示。
{
"WindowTargetId":"e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE"
}
- Linux & macOS
-
aws ssm register-target-with-maintenance-window \
--window-id mw-9a8b7c6d5eEXAMPLE \
--targets "Key=tag:PatchGroup,Values=Front-End Servers" \
--owner-information "Front-End Servers" \
--resource-type "INSTANCE"
- Windows Server
-
aws ssm register-target-with-maintenance-window ^
--window-id mw-9a8b7c6d5eEXAMPLE ^
--targets "Key=tag:PatchGroup,Values=Front-End Servers" ^
--owner-information "Front-End Servers" ^
--resource-type "INSTANCE"
系統會傳回相關資訊,如下所示。
{
"WindowTargetId":"faa01c41-1d57-496c-ba77-ff9caEXAMPLE"
}
-
執行下列命令以註冊修補程式任務,該任務會在 Database
和 Front-End
伺服器各自的維護時段上安裝伺服器缺少的更新。
- Linux & macOS
-
aws ssm register-task-with-maintenance-window \
--window-id mw-0c50858d01EXAMPLE \
--targets "Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE" \
--task-arn "AWS-RunPatchBaseline" \
--service-role-arn "arn:aws:iam::123456789012:role/MW-Role" \
--task-type "RUN_COMMAND" \
--max-concurrency 2 \
--max-errors 1 \
--priority 1 \
--task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
- Windows Server
-
aws ssm register-task-with-maintenance-window ^
--window-id mw-0c50858d01EXAMPLE ^
--targets "Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE" ^
--task-arn "AWS-RunPatchBaseline" ^
--service-role-arn "arn:aws:iam::123456789012:role/MW-Role" ^
--task-type "RUN_COMMAND" ^
--max-concurrency 2 ^
--max-errors 1 ^
--priority 1 ^
--task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
系統會傳回相關資訊,如下所示。
{
"WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE"
}
- Linux & macOS
-
aws ssm register-task-with-maintenance-window \
--window-id mw-9a8b7c6d5eEXAMPLE \
--targets "Key=WindowTargetIds,Values=faa01c41-1d57-496c-ba77-ff9caEXAMPLE" \
--task-arn "AWS-RunPatchBaseline" \
--service-role-arn "arn:aws:iam::123456789012:role/MW-Role" \
--task-type "RUN_COMMAND" \
--max-concurrency 2 \
--max-errors 1 \
--priority 1 \
--task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
- Windows Server
-
aws ssm register-task-with-maintenance-window ^
--window-id mw-9a8b7c6d5eEXAMPLE ^
--targets "Key=WindowTargetIds,Values=faa01c41-1d57-496c-ba77-ff9caEXAMPLE" ^
--task-arn "AWS-RunPatchBaseline" ^
--service-role-arn "arn:aws:iam::123456789012:role/MW-Role" ^
--task-type "RUN_COMMAND" ^
--max-concurrency 2 ^
--max-errors 1 ^
--priority 1 ^
--task-invocation-parameters "RunCommand={Parameters={Operation=Install}}"
系統會傳回相關資訊,如下所示。
{
"WindowTaskId":"8a5c4629-31b0-4edd-8aea-33698EXAMPLE"
}
-
執行以下命令以取得修補程式群組的高階修補程式合規摘要。高階修補程式合規摘要包括處於各別修補程式狀態之修補程式的受管節點數目。
在第一個維護時段期間執行修補程式任務之前,摘要中的受管節點數目預計為零。
- Linux & macOS
-
aws ssm describe-patch-group-state \
--patch-group "Database Servers"
- Windows Server
-
aws ssm describe-patch-group-state ^
--patch-group "Database Servers"
系統會傳回相關資訊,如下所示。
{
"Instances": number
,
"InstancesWithFailedPatches": number
,
"InstancesWithInstalledOtherPatches": number
,
"InstancesWithInstalledPatches": number
,
"InstancesWithInstalledPendingRebootPatches": number
,
"InstancesWithInstalledRejectedPatches": number
,
"InstancesWithMissingPatches": number
,
"InstancesWithNotApplicablePatches": number
,
"InstancesWithUnreportedNotApplicablePatches": number
}
-
執行以下命令以取得修補程式群組中各受管節點的修補程式摘要狀態。每個受管節點摘要包括修補群組之每個受管節點中,處於個別修補程式狀態的多個修補程式。
- Linux & macOS
-
aws ssm describe-instance-patch-states-for-patch-group \
--patch-group "Database Servers"
- Windows Server
-
aws ssm describe-instance-patch-states-for-patch-group ^
--patch-group "Database Servers"
系統會傳回相關資訊,如下所示。
{
"InstancePatchStates": [
{
"BaselineId": "string
",
"FailedCount": number
,
"InstalledCount": number
,
"InstalledOtherCount": number
,
"InstalledPendingRebootCount": number
,
"InstalledRejectedCount": number
,
"InstallOverrideList": "string
",
"InstanceId": "string
",
"LastNoRebootInstallOperationTime": number
,
"MissingCount": number
,
"NotApplicableCount": number
,
"Operation": "string
",
"OperationEndTime": number
,
"OperationStartTime": number
,
"OwnerInformation": "string
",
"PatchGroup": "string
",
"RebootOption": "string
",
"SnapshotId": "string
",
"UnreportedNotApplicableCount": number
}
]
}