Skip to content

Cloud CLI: Patching & updates

Cloud CLI commands for patching & updates (tags: #patching).

Index
6 items

AWS: Show ECR scan findings for an image

Safe

Vulnerability counts per severity for an image in ECR. Drop --query to see each finding.

aws ecr describe-image-scan-findings --repository-name <repo> --image-id imageTag=<tag> --query 'imageScanFindings.findingSeverityCounts'
What each part does
  1. describe-image-scan-findingsresults of the last ECR / Inspector scan
  2. --repository-name <repo>ECR repository
  3. --image-id imageTag=<tag>which image
  4. --query ...only the CRITICAL/HIGH/... counts
  • #aws
  • #patching
  • #vulnerabilities

Also known as: ecr scan results · ecr vulnerabilities · inspector findings

AWS: Rescan an image in ECR

Safe

Re-run a basic ECR scan after pushing a patched image. (Enhanced / Inspector scanning rescans on its own.)

aws ecr start-image-scan --repository-name <repo> --image-id imageTag=<tag>
What each part does
  1. start-image-scanstart a basic scan
  2. --repository-name <repo>ECR repository
  3. --image-id imageTag=<tag>which image
  • #aws
  • #patching
  • #vulnerabilities

Also known as: ecr rescan · ecr scan image

AWS: Get the latest ECS-optimized AMI ID

Safe

ECS hosts (kernel, docker, containerd, nvidia toolkit) are patched by rolling to the newest AMI.

aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id --query 'Parameters[0].Value' --output text
What each part does
  1. ssm get-parametersread a public AWS parameter
  2. /aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_idlatest AL2023 ECS AMI (…/amazon-linux-2023/gpu/… for GPU hosts)
  3. --query 'Parameters[0].Value' --output textprint only the AMI ID

My note Put the ID in the launch template, then refresh the Auto Scaling group: aws autoscaling start-instance-refresh --auto-scaling-group-name <asg>

  • #aws
  • #patching
  • #kernel

Also known as: ecs ami · latest ami · ecs optimized ami · patch ecs host

AWS: Scan instances for missing patches with SSM

Safe

Reports missing patches without installing anything. Works on many instances at once (Key=tag:<name>,Values=<value>).

aws ssm send-command --document-name AWS-RunPatchBaseline --targets Key=InstanceIds,Values=<instance-id> --parameters Operation=Scan
What each part does
  1. send-command --document-name AWS-RunPatchBaselinerun the AWS patching document
  2. --targets Key=InstanceIds,Values=<instance-id>which instances (comma-separated, or use tags)
  3. Operation=Scanreport only
  • #aws
  • #patching

Also known as: patch manager scan · ssm patch scan · missing patches

AWS: Install patches with SSM and reboot if needed

Caution

Patches the instances from the patch baseline and reboots them only if a patch requires it.

aws ssm send-command --document-name AWS-RunPatchBaseline --targets Key=InstanceIds,Values=<instance-id> --parameters Operation=Install,RebootOption=RebootIfNeeded
What each part does
  1. AWS-RunPatchBaselineAWS patching document (Linux and Windows)
  2. Operation=Installinstall missing patches
  3. RebootOption=RebootIfNeededreboot only when needed (NoReboot to skip)
  • #aws
  • #patching
  • #kernel

Also known as: patch manager install · ssm patch · patch fleet · patch windows

AWS: Check the patch state of an instance

Safe

Installed, missing and failed patch counts, plus when the last scan or install ran.

aws ssm describe-instance-patch-states --instance-ids <instance-id>
What each part does
  1. describe-instance-patch-statespatch compliance summary
  2. --instance-ids <instance-id>one or more instances
  • #aws
  • #patching

Also known as: patch compliance · patch status · missing patch count

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…