Skip to content

Add AWS onboarding engine, library-only (onboarding 2/3) - #6

Draft
droth-plerion wants to merge 2 commits into
plerionhq:mainfrom
droth-plerion:feat/onboard-engine
Draft

Add AWS onboarding engine, library-only (onboarding 2/3)#6
droth-plerion wants to merge 2 commits into
plerionhq:mainfrom
droth-plerion:feat/onboard-engine

Conversation

@droth-plerion

Copy link
Copy Markdown

2 of 3 in the integrations add aws series (token plumbing → this → CLI command). Stacked on the plumbing PR — review only the last commit. Jira: PL-5466 · APPP-15.

What

The onboarding engine as a library-only module (src/onboard/) — no CLI surface change. It orchestrates end-to-end AWS account onboarding:

external-id → pinned template (+ opportunistic serviceAccountId pickup) → preflight → confirmation seam → short-lived registration token (minted last) → CreateStack (CAPABILITY_NAMED_IAM, OnFailure=ROLLBACK) → poll with failure-event reporting → outputs.

Preflight encodes two lessons from a live onboarding run:

  1. iam:SimulatePrincipalPolicy reports false denials for Identity Center admins (reproduced with full AdministratorAccess) → simulation is advisory by default, fatal only with strict mode.
  2. Same-name stack checks miss console onboardings → duplicate detection scans IAM roles (*PlerionAccessRole*, any stack name) and the tenant's integrations list.

Design

  • AwsApi trait with owned domain types; sdk.rs is the only file importing aws-sdk-*. The state machine is unit-testable without AWS.
  • New deps: aws-config + aws-sdk-sts/iam/cloudformation + async-trait. Please run the 5-target cross release build on this branch — aws-lc-rs under cross/musl is the known risk; fallback is pinning a ring-based rustls HTTP client via SdkConfig::http_client.
  • The AuthToken is never rendered on any path (dry-run plan, errors, logs).

Testing

17 scenarios in tests/onboard_test.rs with a scripted AwsApi + ScriptedUi + mockito Plerion server: happy path, account-guard mismatch, ROLLBACK_COMPLETE hint, duplicate confirm/deny/allow-existing/non-interactive, advisory vs strict simulation, simulation-unavailable, deploy failure with expired-token hint, timeout, stack-name prefix rule, missing service-account guidance. Zero warnings, clippy clean.

🤖 Generated with Claude Code

droth-plerion and others added 2 commits July 23, 2026 13:23
generate_token now takes Option<&str>: Some(id) keeps the existing
integration-scoped behavior (aws generate-token is unchanged), None issues
the bare POST that mints an onboarding token for registering a new AWS
account. New typed envelope models for the three AWS endpoints; the raw
subcommands keep returning serde_json::Value so their output is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 2c1bffa)
Library-only orchestration for end-to-end AWS account onboarding, behind
an AwsApi trait so the state machine is unit-testable without AWS
(aws-sdk-* types are confined to sdk.rs). Covers preflight (STS account
resolution, stack conflicts, duplicate detection via IAM roles AND the
tenant integration list, advisory IAM simulation tolerant of Identity
Center false negatives, template validation), a short-lived registration
token minted last, CreateStack with CAPABILITY_NAMED_IAM, polling with
failure-event reporting, and an offline dry-run plan renderer with the
AuthToken always redacted.

No CLI surface change in this commit — the command lands next.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@droth-plerion

Copy link
Copy Markdown
Author

Series: #5 (token plumbing) → #6 (onboarding engine, stacked on #5) → #7 (CLI command, stacked on #6). Merge in order; each is independently green (build, tests, clippy). Supersedes #4.

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.

1 participant