amitkarpe/agent-skills/cis-inspector-scan

Claude Code and agent skill by amitkarpe/agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Run an AWS Inspector CIS scan on a single EC2 instance, enforce readiness rules, fetch results, and save durable evidence with recovery-aware bash helpers.

Install

npx vskill@latest install amitkarpe/agent-skills/cis-inspector-scan

SKILL.md

The same SKILL.md was published earlier as amitkarpe/agent-skills/cis-inspector-scan.

CIS Inspector Scan

Run an AWS Inspector CIS scan on a single EC2 instance, enforce readiness rules, fetch results, and save durable evidence.

When to use this skill

  • Run an Inspector CIS scan on an EC2 instance
  • Recover a previous scan by config ARN
  • Validate Inspector CIS readiness before scanning
  • Fetch and archive failed CIS controls

Readiness rules (enforced by scripts)

A result is only valid when:

  • status = COMPLETED
  • totalChecks > 0

If either condition fails, the scripts exit non-zero. Partial evidence (scan.json) is saved to help with troubleshooting, but aggregated-checks.json and failed-controls.json are not created.

Quick start

Prerequisites: The target instance must have a tag instance_id=<instance-id>. Add it if missing:

bash
aws ec2 create-tags \
--resources <i-xxx> \
--tags Key=instance_id,Value=<i-xxx> \
--profile <aws-profile> \
--region <region>
Single-command pipeline (recommended)
bash
OUTDIR=~/.AGENTS-temp/<repo>/inspector-$(date +%Y%m%d-%H%M%S)
mkdir -p "$OUTDIR"
bash scripts/inspector_cis_full_pipeline.sh \
--profile <aws-profile> \
--region <region> \
--instance-id <i-xxx> \
--scan-name my-cis-scan-$(date +%Y%m%d) \
--output-dir "$OUTDIR"

Exits 0 only on valid result. Auto-recovers once on timeout.

Cleanup before scan (if stale configs exist)
bash
bash scripts/inspector_cis_cleanup.sh \
--profile <aws-profile> \
--region <region> \
--instance-id <i-xxx>
Manual step-by-step workflow
bash
OUTDIR=~/.AGENTS-temp/<repo>/inspector-$(date +%Y%m%d-%H%M%S)
mkdir -p "$OUTDIR"
# 1. Preflight
bash scripts/inspector_cis_preflight.sh \
--profile <aws-profile> \
--region <region> \
--instance-id <i-xxx> \
--output-dir "$OUTDIR"
# 2. Create scan (or recover existing)
bash scripts/inspector_cis_create_or_recover_scan.sh \
--profile <aws-profile> \
--region <region> \
--instance-id <i-xxx> \
--scan-name my-cis-scan-$(date +%Y%m%d) \
--security-level LEVEL_2 \
--output-dir "$OUTDIR"
# Extract the config ARN for next step
SCAN_CONFIG_ARN=$(cat "$OUTDIR/scan-config-arn.txt")
# 3. Fetch results (polls until COMPLETED or failure)
bash scripts/inspector_cis_fetch_results.sh \
--profile <aws-profile> \
--region <region> \
--scan-config-arn "$SCAN_CONFIG_ARN" \
--output-dir "$OUTDIR"
# 4. Reduce to failed controls only
bash scripts/inspector_cis_reduce_failed_controls.sh \
--output-dir "$OUTDIR"

To recover an existing scan config instead of creating a new one:

bash
# Skip step 2, use existing ARN directly in step 3
bash scripts/inspector_cis_create_or_recover_scan.sh \
--profile <aws-profile> \
--region <region> \
--scan-config-arn <existing-arn> \
--output-dir "$OUTDIR"
SCAN_CONFIG_ARN=$(cat "$OUTDIR/scan-config-arn.txt")
# Continue with step 3...

Script flags

FlagScriptsRequired
--profilepreflight, create, fetchyes
--regionpreflight, create, fetchyes
--instance-idpreflight, createyes (create: only if not recovering)
--output-dirallyes
--scan-config-arncreate (recovery), fetchconditional
--scan-namecreateyes (new scan)
--security-levelcreateno (default: LEVEL_2)

Note: inspector_cis_reduce_failed_controls.sh only requires --output-dir.

Evidence saved

FileDescription
preflight.jsonPreflight check results
scan-config.jsonRaw scan configuration from Inspector
scan.jsonRaw scan row (status, counts, ARNs)
aggregated-targets.jsonRaw target aggregation for invalid scans when the diagnostic query succeeds
target-status.jsonConcise status and reason for each target, or a diagnostic error when the query fails
aggregated-checks.jsonFull aggregated check results
failed-controls.jsonReduced: only checks with failed count > 0

Known failure modes

SymptomLikely causeResolution
totalChecks = 0Metadata tags disabled, wrong accountIds, IAM gap, endpoint/DNS issueCheck preflight items in order
Failed to get instance tags from instance metadataInstanceMetadataTags not enabledEnable via modify-instance-metadata-options
ConflictExceptionStale scan config from cancelled runAuto-cleaned by create script (v2)
status = FAILEDSSM agent unhealthy, IAM missing AmazonInspector2ManagedCisPolicyFix IAM/SSM, retry
Infinite polling loop(Fixed in v2)Fetch script now uses list-all + Python filter

Note: The create script automatically detects and deletes stale scan configs targeting the same instance before creating a new one. This prevents ConflictException from cancelled runs. The fetch script uses list-cis-scans (all) with Python filtering instead of --filter-criteria to avoid bash quoting issues.

IAM requirements

Instance profile must include:

  • AmazonSSMManagedInstanceCore
  • AmazonInspector2ManagedCisPolicy

References

  • references/inspector-workflow.md — step-by-step workflow and polling rules
  • references/source-artifacts.md — proven scan examples and check counts

Cleanup

After a scan completes, the scan config remains in Inspector. To avoid config sprawl:

bash
# List existing configs
aws inspector2 list-cis-scan-configurations \
--profile <aws-profile> \
--region <region>
# Delete a config after use
aws inspector2 delete-cis-scan-configuration \
--scan-configuration-arn <arn> \
--profile <aws-profile> \
--region <region>

One-time scan configs can be deleted immediately after fetching results.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/amitkarpe/agent-skills/cis-inspector-scan/badge)](https://verified-skill.com/skills/amitkarpe/agent-skills/cis-inspector-scan)

Something wrong with this skill or its page? Tell us.