Skip to content

chore: remove awsenv package and bootstrap cmd#14

Merged
iBakuman merged 1 commit into
mainfrom
feature/implement-auto-refresh-aws-session
May 15, 2026
Merged

chore: remove awsenv package and bootstrap cmd#14
iBakuman merged 1 commit into
mainfrom
feature/implement-auto-refresh-aws-session

Conversation

@iBakuman
Copy link
Copy Markdown
Contributor

Summary

  • Delete awsenv/ package and cmd/awsenv-bootstrap/ (only purpose was calling awsenv.Ensure).
  • go mod tidy drops gofrs/flock, joho/godotenv, and demotes aws-sdk-go-v2/service/sts to indirect.

Why

awsenv.Ensure ran oidc2aws -alias <x> --env, wrote the output to a project-root .aws.env, and loaded those values into the process environment via godotenv.Overload. After that, the AWS SDK saw AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN as static env-var credentials — the env provider has no notion of expiry, so long-running processes kept using stale tokens until calls started failing.

The standard fix is AWS's credential_process protocol: declare each profile in ~/.aws/config with

[profile qor5-test]
credential_process = oidc2aws -alias qor5-test

and set AWS_PROFILE / AWS_REGION. The SDK v2's CredentialsCache then re-invokes oidc2aws on demand and refreshes credentials transparently before expiry — exactly what awsenv was trying (and failing) to do.

Since the SDK handles this natively, the Go-side bootstrap is dead weight and is removed entirely.

Caller update

github.com/theplant/iam is the only external caller. Its companion PR removes the awsenv.Ensure call from iam/cmd/console/local_server_test.go.

Test plan

  • go build ./...
  • go vet ./...
  • Downstream iam repo PR merges its caller-removal change

🤖 Generated with Claude Code

The awsenv package loaded AWS credentials by writing oidc2aws output to
.aws.env and overloading them into the process environment. Once the
SDK picked them up via the env-var provider they became static — the
SDK had no way to refresh them, so sessions expired during long-running
processes.

The replacement is AWS's standard credential_process mechanism: declare
the profile in ~/.aws/config with `credential_process = oidc2aws ...`
and set AWS_PROFILE. The SDK's CredentialsCache then invokes oidc2aws
on demand and auto-refreshes before expiry, with no in-process
bookkeeping required.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@iBakuman iBakuman merged commit c88046d into main May 15, 2026
2 checks passed
@iBakuman iBakuman deleted the feature/implement-auto-refresh-aws-session branch May 15, 2026 09:53
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.

2 participants