agentleFS
aws-solutions-library-samplesaws-solutions-library-samples/accelerated-intelligent-document-processing-on-aws/.claude/skills/run-stack-tests/SKILL.md

run-stack-tests

Skill329 starsChanged 6 days agoMIT-0View on GitHub

Use when running the deploy-variant stack tests (make stacktest-*: ZAP DAST, Jobs API, WAF, API Gateway hosting) manually against a live stack.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this when the user wants to run one of the deploy-variant stack-tests or other live-stack integration tests outside the CI pipeline — …

    line 8
  2. Very specific:

    Always use AWS_PROFILE=default (or idp-ci) — see CLAUDE.md.

    line 55
  3. Very specific:

    Look for a usable VPC/subnets/SG/endpoint in the target account:

    line 128
  4. Very specific:

    Prefer a VPC that already has private subnets and an execute-api interface endpoint (the private API hosting test needs one).

    line 139
  5. Distinctive:

    If no suitable VPC exists, tell the user — offer to self-create one only if they ask (it is slow and adds VPC-quota pressure).

    line 152

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Run stack-tests (stacktest-*) manually

Use this when the user wants to run one of the deploy-variant stack-tests or other live-stack integration tests outside the CI pipeline — e.g. "run the ZAP scan against my stack", "test the Jobs API deploys", "check WAF hosting", "run the private API hosting test", "verify the permissions boundary". These used to run automatically on every integration pipeline; they were moved to on-demand make stacktest-* targets because standing up ~6 stacks at once in one pipeline burst the account-wide AWS control planes (CloudWatch Logs create-consistency, CodeBuild role-trust propagation, IAM CreatePolicy rate limit) and caused flaky failures unrelated to the code under test. In CI the deploy-variant probes (ZAP DAST, WAF, API Gateway GLOBAL and PRIVATE, Jobs API, tenant isolation) run only on the weekly variant-probe schedule (a GitLab project setting; they run only while it is active), never on the nightly; stacktest-rbac is make api-test, which every integration run already executes as a step of the primary suite, and the other stacktest-* targets run only by hand; see scripts/sdlc/docs/CI_TEST_COVERAGE.md (Pipeline stages & triggers).

The stacktest family

TargetWhat it doesNeeds
make stacktest-listList the deploy-variant stack-tests—
make stacktest-rbac STACK_NAME=…Full RBAC/authorization matrix (alias of api-test)live stack
make stacktest-zapOWASP ZAP DAST scan of the UI APIstack or self-deploy
make stacktest-inbox STACK_NAME=…Inbox end to end: posts through idp_common.notifications (direct, group fan-out, idempotency, dedupe) and reads back through the REST API (list, unread count, mark read, cross-user 404). Creates and removes a temporary Cognito group inbox-live-check-<rand>, two temporary users and their Inbox items, and restores the app client's auth flows. Exit 0 = PASS, 1 = FAIL, 2 = errored or skippedlive stack deployed with the Inbox (NotificationsTableName output; an older stack reports SKIP)
make stacktest-review-queues STACK_NAME=…Review queues end to end on the Annotator path: uploads a sample under a temporary profile with HITL on (hitl.confidence_threshold: 0.99), creates a temporary Annotator and a temporary Admin, checks the Annotator sees no queue while unlisted, has the Admin add the Annotator to the Default queue's Eligible Annotators through updateReviewQueue (sending back the settings an update would otherwise reset, and leaving out enabled and the skip reasons, which an update keeps), waits for review/status.json = in_review, then lists, claims, saves a draft and completes through the REST API as the Annotator, and waits for complete, tracking COMPLETED, an unchanged machine manifest and a final manifest. Cleanup takes only that Annotator off the Default queue's list, from a fresh read, and removes the profile, both users, the document and its queue and tracking rows, and restores the app client's auth flows. A disabled Default queue is reported as could-not-run rather than switched on. CHECK_EVENTS=1 also expects the two status-object EventBridge events via a temporary rule and SQS queue. Costs one document's processing. Exit 0 = PASS, 1 = FAIL, 2 = errored or skippedlive stack deployed with review queues (HITLTableName output; an older or headless stack reports SKIP) and its Default queue enabled (the seeded state). ⚠️ While it runs, the Default queue lists one extra Annotator, and a cleanup that cannot remove it is reported as a FAIL naming the user. updateReviewQueue writes the whole definition unconditionally from a read the resolver may have cached for up to 30 seconds, so an Admin edit to the Default queue's name, description, priority, checklist, reject reasons, time limit or Eligible Annotators within about 30 seconds of either of the check's two writes can be lost, and two concurrent runs can drop each other's Annotator. Run it when nobody is editing that queue
make stacktest-load STACK_NAME=…Load probe: one new loadprobe-<run id>-<arm> profile per arm (split-then-classify, holistic packet classification, agentic extraction, and decision-model confidence when --decision-model-endpoint is passed), a few dozen sample packets submitted at once, a deadline; fails on any document failed for a transient or unreadable cause and on any section with values but no confidence, and reports step retries as a trend. DRY_RUN=1 validates the plan and configurations offline and touches nothing; driver options go in LOAD_PROBE_ARGS="…" (--docs-per-arm, --max-documents, --max-cost-usd, --deadline-minutes, --cleanup never|on-pass|always). Report in scratch/load-probe/<run id>/report.json. In CI only on its own weekly schedule (IDP_RUN_LOAD_PROBE=true); see scripts/sdlc/docs/CI_TEST_COVERAGE.md ("Weekly load probe")live stack; spends Bedrock and Textract money under an estimated-cost cap
make stacktest-decision-window STACK_NAME=…Decision-model window check (#2051): reads the endpoint from the host's <host>-feature-decision-model-decider stack (DeciderEndpoint), or takes ENDPOINT=…; INSTALL=1 installs that extension from this checkout first (BUCKET_BASENAME=… for its artifacts) and refuses a host that already has it; UNINSTALL=1, which needs INSTALL=1, deletes the extension stack this run created afterwards, pass or fail, and a failed uninstall makes a passing run exit 2. Only 1, true or yes turn either on. Sends digit-only calibration probes (the decider's prompt overhead, a request just under and just over CONTEXT_WINDOW_TOKENS, a square and a portrait page image), then the largest request each caller builds with its own code; fails on a size refusal, a measured count above the estimate plus PROMPT_RESERVE_TOKENS, or a window, prompt or image cost that no longer matches the constants. Requests go one at a time, and the first to a new execution environment loads the model. Report in scratch/window-check/<timestamp>/report.json. In neither CIa host stack (the extension is installed on it), or a deployed decider
make stacktest-hosting-globalAPIGateway GLOBAL hosting variantstack or self-deploy
make stacktest-wafWAF IP-allow-list WebACL associationstack or self-deploy
make stacktest-hosting-privatePRIVATE (VPC) API hostingVPC + stack/self-deploy
make stacktest-jobsapiJobs REST API (EnableJobsApi)VPC + stack/self-deploy
make stacktest-tenancyTenant isolation: deploys TenantIsolationMode=Strict and runs the verify-tenant-isolation harness (cross-tenant read and upload refusals, strict-mode ingest refusals, generated access points). Processes a real document per tenantStrict stack or self-deploy; credentials that can create IAM roles and a CloudFormation stack
make stacktest-sellerSeller Entitlement Service e2e (deploys + tears down its own stack)seller-account creds; no listing needed
make stacktest-sandbox-networkNetwork reach of the analytics agent's Python interpreter (aws.codeinterpreter.v1, the AWS-managed Bedrock AgentCore Code Interpreter): runs a fixed probe program in a session and reports DNS (example.com, the regional S3 endpoint), HTTPS to example.com, a PUT to a presigned URL for a throwaway bucket ab-sandbox-probe-<random> and whether the object arrived, raw TCP to 1.1.1.1:443, TCP to S3 in another region, HTTPS to regional STS, whether the instance metadata service answers, and whether any AWS credential source (environment, ~/.aws files, metadata role, container endpoint) is present, by presence only. Each is compared with EXPECTED_POSTURE in scripts/sdlc/sandbox_network_probe.py. Exit 0 = matches, 1 = the posture changed (in either direction), 2 = could not run. When it changes, re-measure, update EXPECTED_POSTURE and the network statement in docs/agent-analysis.md together. Manual only: it needs credentials that can start an interpreter session and create a bucket, and the GitLab CI job role (scripts/sdlc/cfn/credential-vendor.yml) grants neither, so it is not on the weekly schedule. Default REGION=us-west-2, the only region measuredcredentials for the account; no stack
make stacktest-benchmarkRelease-vs-release benchmark audit (alias)see run-benchmarks
make stacktest-upgradeIn-place upgrade test pointersee test-upgrade

Two modes

  1. Validate an existing stack (fast, preferred): make stacktest-zap STACK_NAME=<already-deployed-stack> — runs only the validator against a stack the user already has. No deploy, no teardown.
  2. Self-deploy a throwaway stack: omit STACK_NAME and pass TEMPLATE_URL=<idp-main.yaml from publish.py>. Deploys its own stack, validates, and tears it down. Slower (~30 min deploy).

Always use AWS_PROFILE=default (or idp-ci) — see CLAUDE.md.

Region: the validators read AWS_DEFAULT_REGION (default us-east-1), NOT the active profile's configured region. If your stack is elsewhere, pass REGION= — e.g. make stacktest-zap STACK_NAME=IDP1 REGION=us-west-2. Omitting it when the stack isn't in us-east-1 fails with "stack does not exist".

Reading the ZAP report

make stacktest-zap prints a self-contained report block covering EVERY rule outcome, not just the findings:

🔎 ZAP DAST scan report
  Target:      https://<id>.execute-api.<region>.amazonaws.com/api
  Operations:  96 seeded (POST /op/<field>)
  Mode:        passive baseline        # or "active scan" (IDP_ZAP_ACTIVE=true)
  Rules:       114 PASS · 3 WARN · 0 FAIL · 1 IGNORE
  Alerts:      High=0 Medium=1 Low=3 Info=2
  Findings (most severe first):
    • [Medium] Cross-Domain Misconfiguration — 5 instance(s)
        https://.../op/abortWorkflow
        ↳ fix: <ZAP remediation hint>
  Report:      /path/to/zap-report.html   (+ .json)
  • Rules: is the full tally from zap-api-scan — PASS shows how much was actually exercised (a big PASS count is the "nothing found" signal), FAIL/WARN are the actionable ones, IGNORE are rules muted in scripts/sdlc/zap-rules.conf.
  • Findings lists every alert (all severities) with sample affected URLs and ZAP's remediation hint — actionable without opening the HTML report.
  • Report: is the full HTML/JSON/MD report on disk. make stacktest-zap writes it to ./scratch/zap-reports/ by default (scratch is gitignored, so a run never litters the tree); override with REPORT_DIR=./somewhere. Open scratch/zap-reports/zap-report.html in a browser for the full findings view. (The RBAC test similarly defaults to ./scratch/api-test-results/.) In CI (SOURCE_BUCKET set) the report is also uploaded to S3 and shown as Report (S3):.
  • The probe is WARN-only: it PASSES even with findings (0 High/FAIL is the expected clean state). To gate on findings, promote a rule WARN→FAIL in zap-rules.conf and flip the # TODO promote gate in validate_zap_dast.
  • To tune what's reported: edit scripts/sdlc/zap-rules.conf (IGNORE known-noise plugin ids, or WARN/FAIL to change severity).

Tenant isolation (tenancy)

make stacktest-tenancy runs scripts/security/live_checks/verify_tenant_isolation.py — the same harness as make verify-tenant-isolation — through the probe runner, so its verdict is the weekly probe's verdict.

  • Against an existing stack (STACK_NAME=…), that stack must already be deployed with TenantIsolationMode=Strict; the harness refuses any other mode with exit 2 and creates nothing. Prefer make verify-tenant-isolation STACK_NAME=… there if you want its confirmation prompt; the probe form passes --yes.
  • Self-deploy (TEMPLATE_URL=…) deploys a fresh Strict stack, runs the harness and tears the stack down, exactly as the weekly run does.
  • Either way it creates and removes two throwaway Configuration Profiles, two tenants over tenancy-verify/a/ and tenancy-verify/b/, throwaway Cognito users, two IAM roles idp-tiv-uploader-<tenant>-<hex> (no permissions boundary) and an access point stack <stack>-tiv-ap-<hex>, all in a finally. A run killed before that finally can leave the two roles behind: no CI reaper removes them, so list idp-tiv-uploader-* roles after an interrupted run.
  • It passes only when the harness exits 0, prints a complete <passed>/<total> PASS tally, and reports at least one verify: row (the cross-tenant read refusals). The tally is printed as tenancy_checks on success; on failure the first failing rows are in the error.
  • Pass REGION= when the stack is not in us-east-1; the runner reads AWS_DEFAULT_REGION, while make verify-tenant-isolation defaults to us-west-2.

VPC tests (hosting-private, jobsapi) — auto-discover a VPC, then CONFIRM

These need VPC wiring. Prefer discovering a suitable existing VPC in the account over creating one. Procedure:

  1. Look for a usable VPC/subnets/SG/endpoint in the target account:
    AWS_PROFILE=default aws ec2 describe-vpcs \
      --query 'Vpcs[].{Id:VpcId,Cidr:CidrBlock,Default:IsDefault,Tags:Tags}' --output json
    AWS_PROFILE=default aws ec2 describe-subnets --filters Name=vpc-id,Values=<vpc> \
      --query 'Subnets[].{Id:SubnetId,AZ:AvailabilityZone,Public:MapPublicIpOnLaunch}' --output json
    AWS_PROFILE=default aws ec2 describe-security-groups --filters Name=vpc-id,Values=<vpc> \
      --query 'SecurityGroups[].{Id:GroupId,Name:GroupName}' --output json
    AWS_PROFILE=default aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=<vpc> \
      --query 'VpcEndpoints[?ServiceName==`com.amazonaws.<region>.execute-api`].VpcEndpointId' --output json
    Prefer a VPC that already has private subnets and an execute-api interface endpoint (the private API hosting test needs one). Check the pipeline's persistent test VPC first — it is purpose-built for this.
  2. Show the user what you found and CONFIRM before running — never auto-pick and deploy into a VPC silently. Present the VPC id, subnets, SG, and endpoint you intend to use and ask them to approve.
  3. On approval, run with make params (NOT env vars):
    AWS_PROFILE=default make stacktest-jobsapi \
      STACK_NAME=<stack> \
      VPC_ID=<vpc> SUBNET_IDS=<subnet-a,subnet-b> \
      LAMBDA_SG_ID=<sg> APIGW_VPCE_ID=<vpce>
  4. If no suitable VPC exists, tell the user — offer to self-create one only if they ask (it is slow and adds VPC-quota pressure); do not create one by default.

Notes

  • These reuse the SAME deploy/validate/cleanup code as CI: the runner (scripts/sdlc/run_stacktest.py) imports codebuild_deployment.py and drives its internal deploy-variant table, so results match what CI would have produced — no drift.
  • To run all the deploy-variant tests inside a pipeline, press Run on the weekly variant-probe schedule (a GitLab project setting under Build › Pipeline schedules, carrying IDP_RUN_PROBES=true; the button exists only once the schedule does). IDP_RUN_PROBES=true is honoured only on a scheduled pipeline, so setting it on a manual or merge-request run does nothing; on the build side it is off unless the buildspec sets it.
  • Permissions boundary is now verified only by the primary suite (Step 13, test_step13_permission_boundaries); the deploy-variant tests deploy without one.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.