Skip to content

feat(aws): add javabin aws setup and aws doctor for SSO profiles - #8

Merged
Alexanderamiri merged 2 commits into
mainfrom
feat/aws-setup
Oct 24, 2026
Merged

Alexanderamiri merged 2 commits into
mainfrom
feat/aws-setup

Conversation

@Alexanderamiri

Copy link
Copy Markdown
Member

Why

Without AWS_PROFILE, team commands fell through to EC2 IMDS and timed out, and users had to hand-write sso-session/profile blocks in ~/.aws/config.

What

  • javabin aws setup [--dry-run] [--no-login] [--force]: ensures [sso-session javabin] (javaBin Identity Center, eu-central-1, sso:account:access) in AWS_CONFIG_FILE/~/.aws/config; runs aws sso login --sso-session javabin (install hint if aws missing); reads the cached token (~/.aws/sso/cache/<sha1(javabin)>.json, checks expiresAt); calls SSO ListAccountRoles for 553637109631; writes one profile per role.
  • Profile naming: profile name = role name (javabin-team-cupcake, javabin-developer, javabin-admin, javabin-readonly); a role without the javabin- prefix gets one. sso_session = javabin, account, role, region = eu-central-1.
  • Safety: existing profiles are never edited or deleted (differences reported); a role already used by another profile in the account is not duplicated (keeps secret's auto-pick unambiguous); a javabin session with another start URL stops unless --force; backup to config.bak-<timestamp>, atomic write, mode 0600.
  • javabin aws doctor: session block, token validity, and the profile secret would use for app.yaml.
  • New internal/awsconfig package: line-preserving INI editing (comments, order, nested sub-properties untouched), token cache, RoleLister interface.
  • credentialsHelp now suggests javabin aws setup instead of aws configure sso.
  • Adds github.com/aws/aws-sdk-go-v2/service/sso as a direct dependency (was indirect at the same version).
  • README and CLAUDE.md updated.

Checks

  • gofmt -l . clean, go vet ./..., go test ./... pass.
  • Tests: empty file, file with other profiles (byte-identical prefix), idempotency, session conflict and --force, conflicting profile left alone, role covered by another profile, backup + 0600, token cache (fake dir, valid/expired/missing), end-to-end setup with fake login + RoleLister, dry-run writes nothing.
  • Smoke: aws setup --dry-run and aws doctor against an empty temp HOME. No real aws sso login was run.

🤖 Generated with Claude Code

Alexanderamiri and others added 2 commits October 24, 2026 12:06
Developers no longer hand-write sso-session/profile blocks. `aws setup`
adds [sso-session javabin], runs `aws sso login --sso-session javabin`,
lists the user's roles in 553637109631 via SSO ListAccountRoles and writes
one profile per role, named after the role (javabin-team-<team>, ...).
Existing profiles are never modified; the config is backed up and written
atomically with mode 0600. credentialsHelp now points at `javabin aws setup`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- WriteFile resolves a symlinked config (EvalSymlinks, dangling links too)
  and replaces/backs up the target instead of the link.
- A role counts as covered only by a profile on sso_session javabin; other
  sessions get a javabin-team profile plus a warning, and roles with
  several profiles report that auto-discovery is off and how to fix it.
- Set inserts new keys after indented sub-property blocks.
- Accept "[profile a] # note" headers; conflict message names the role;
  check for the AWS CLI before writing; doctor tolerates a trailing / or #.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Alexanderamiri
Alexanderamiri merged commit 6625a63 into main Oct 24, 2026
1 check passed
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