Visitar URL original
cli/cloud: add `pulumi insights account scan list` and `scan get` by aacotroneo · Pull Request #23255 · pulumi/pulumi · GitHub
Skip to content

cli/cloud: add pulumi insights account scan list and scan get - #23255

Merged
pgavlin merged 1 commit into
masterfrom
aa/insights-scan-discovery
May 19, 2026
Merged

pgavlin merged 1 commit into
masterfrom
aa/insights-scan-discovery

Conversation

@aacotroneo

@aacotroneo aacotroneo commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes "no way to discover scan IDs from the CLI."

Two new subcommands fill in the gap between triggering a scan and reading its logs:

  • pulumi insights account scan list <account> — recent scans, with IDs.
  • pulumi insights account scan get <account> <scan-id> — full workflow run for one scan.

Combined with the existing account scan (trigger) and account scan log (logs), users can now drive the entire create → scan → debug flow without going to the UI.

Analogous to pulumi deployment …

Insights scans and Pulumi Deployments share a server-side workflow handler, so this PR deliberately mirrors the existing deployment command family:

Concept Deployments Insights scans
List runs pulumi deployment list pulumi insights account scan list (new)
Get a single run pulumi deployment get pulumi insights account scan get (new)
Fetch logs pulumi deployment log pulumi insights account scan log (existing)

Where they overlap, the new commands copy the deployments-side shape so the two surfaces feel like the same family:

  • scan get text view follows deployment get (%-18s key/value alignment, summary fields, Jobs: <count> only — the full per-job/per-step structure lives in --output json).
  • scan list follows the --count / --all pagination convention (mutually exclusive; --count 0 is a synonym for --all) established by insights account list.
  • Both commands accept the same --org / --output global flags as the rest of the Cloud-Ready CLI surface.

Sample output

account scan list <parent> (spans every child account)

$ pulumi insights account scan list "Michael-Test-AWS" --org pulumi --count 5
┌──────────────────────────────────────┬────────────────────────────┬───────────┬──────────────────────┬──────────┐
│ Scan ID                              │ Account                    │ Status    │ Started              │ Duration │
├──────────────────────────────────────┼────────────────────────────┼───────────┼──────────────────────┼──────────┤
│ 724db660-7363-469a-96dd-50eeddedf08c │ Michael-Test-AWS/us-west-1 │ succeeded │ 2026-01-21T15:58:49Z │ 5m30s    │
│ 7bb80f16-8793-4b7c-bbf8-11e8d81f6ca7 │ Michael-Test-AWS/us-east-2 │ succeeded │ 2026-01-21T15:58:47Z │ 44m29s   │
│ 135a8707-0297-48b0-bdf8-0c460ae837d2 │ Michael-Test-AWS/global    │ succeeded │ 2026-01-21T15:58:44Z │ 2m54s    │
│ b4e5a5d2-b9ad-47ee-bc6e-7ec3fb643345 │ Michael-Test-AWS/us-west-1 │ succeeded │ 2026-01-15T22:17:50Z │ 5m35s    │
│ 33f4591d-6f52-494b-8bc8-22356fac0857 │ Michael-Test-AWS/us-east-2 │ succeeded │ 2026-01-15T22:07:16Z │ 45m16s   │
└──────────────────────────────────────┴────────────────────────────┴───────────┴──────────────────────┴──────────┘

account scan get (default text)

$ pulumi insights account scan get "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi
ID:                7bb80f16-8793-4b7c-bbf8-11e8d81f6ca7
Status:            succeeded
Started:           2026-01-21T15:58:47Z
Finished:          2026-01-21T16:43:16Z
Duration:          44m29s
Last updated:      2026-05-19T00:10:57Z
Jobs:              1

account scan get --output json (full workflow run)

{
  "id": "7bb80f16-…",
  "status": "succeeded",
  "startedAt": "2026-01-21T15:58:47.305Z",
  "finishedAt": "2026-01-21T16:43:16.079Z",
  "jobs": [
    {
      "status": "succeeded",
      "started": "2026-01-21T15:59:15.852Z",
      "timeout": 43200000000000,
      "steps": [
        { "name": "Setup", "status": "succeeded" },
        { "name": "Download scanner", "status": "succeeded" },
        { "name": "Install provider", "status": "succeeded" },
        { "name": "Scan account", "status": "succeeded" }
      ],
      "worker": "i-020f6b242e2452051"
    }
  ]
}

Test plan

  • Unit tests: 12 cases for scan list, 7 for scan get (table/JSON rendering, in-flight scans, pagination defaults / --all / --count / --count 0, org+account propagation incl. slash names, factory + client errors, page-loop safety net).
  • mise exec -- make format
  • mise exec -- make lint (0 issues across 7 packages)
  • Live smoke against the pulumi org on Michael-Test-AWS (parent) and Michael-Test-AWS/us-east-2 (leaf), end-to-end scan list → copy ID → scan get <leaf> <id> → scan log <leaf> <id>.

🤖 Generated with Claude Code

These two subcommands close the create → scan → log loop in the CLI by
giving users a way to discover scan IDs and inspect a single scan in
detail. They mirror the `deployment list` / `deployment get` family
exposed for Pulumi Deployments.

  pulumi insights account scan list <account>   # recent scans + IDs
  pulumi insights account scan get <account> <scan-id>

For a parent account, `scan list` returns scans across every child
account. `scan get` wraps GetScan (`/scans/{scanId}`) and returns the
full workflow run; text view follows `deployment get`'s shape
(summary key/value + jobs count), with the per-job/per-step structure
in `--output json`.

Closes the CLI side of pulumi-service#43411 (Issue #4).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aacotroneo
aacotroneo requested a review from a team as a code owner May 19, 2026 00:50
@pgavlin
pgavlin enabled auto-merge May 19, 2026 01:27
@pgavlin
pgavlin added this pull request to the merge queue May 19, 2026
Merged via the queue into master with commit 89c75c0 May 19, 2026
120 checks passed
@pgavlin
pgavlin deleted the aa/insights-scan-discovery branch May 19, 2026 04:04
@pulumi-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped in release v3.242.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants