Access Keys = ポケットに仕掛けた時限爆弾
AWSを使ったことがある人なら一度は経験したことがあるはず:
- IAM Userを作成 → 「Create access key」をクリック
- キーペアを
~/.aws/credentialsに、あるいはもっと悪い場合は.envファイルにコピペ - 間違ってコミットしないように祈る
結果は誰でも知っている:
- 誤ってコミット → 10分後には誰かがあなたのお金でビットコインをマイニング
- キーは自動で期限切れにならない → 一度漏洩したら一年中泣くことに
- 10人のチーム = 退職時に忘れずに無効化すべき10組のキー
2025年11月19日、AWSが素晴らしい機能をリリース:**aws login**コマンド – ブラウザでAWSコンソールにログインするのと全く同じ方法でCLIにログインできる。Access Keyはもう不要、本当に!
aws loginの仕組みは?(Gmailにログインするのと同じくらい簡単)
入力: aws login --profile dev
→ ブラウザで見慣れたAWSログインページが開く
→ いつも通りユーザー名/パスワードを入力 + MFAをスキャン
→ ターミナルに戻る → 完了!一時的な認証情報がすぐに取得される
このトークンは:
- 15分ごとに自動更新(途中で期限切れになる心配なし)
- 最大12時間で再ログインが必要(それでも永久に有効なキーよりはマシ)
本当に5分でセットアップ(母親のパソコンでテスト済み)
ステップ1:AWS CLIをアップデート(必須)
aws --version
# >= 2.32.0 である必要があります
Mac:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Linux:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
ステップ2:IAM Userに「ローカルからログイン」の権限を付与
超簡単な方法が2つあります。どちらか1つを選べばOK:
おすすめの方法:
IAM → User → ポリシーを直接アタッチ → 検索して選択
SignInLocalDevelopmentAccess
(AWSが用意してくれているので、自分で書く必要なし)
手動の方法(コピペが好きな人向け):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"signin:AuthorizeOAuth2Access",
"signin:CreateOAuth2Token"
],
"Resource": "*"
}
]
}
この権限がないと → ブラウザで400エラーが表示され、30分間頭を悩ませることになる。先に警告しておきますよ!
ステップ3:ログインしよう!
aws login --profile dev
# またはdefaultでログイン
aws login
完了したら確認:
aws sts get-caller-identity --profile dev
ARNが表示されたら成功!
よくある「落とし穴」(10秒で脱出する方法)
-
古いAccess Keyが新しいトークンを上書き
→~/.aws/credentialsを開いて、古いキーの行をコメントアウトまたは削除:# [dev] # aws_access_key_id = AKIA... # aws_secret_access_key = xxxx -
環境変数があなたを邪魔する
echo $AWS_ACCESS_KEY_ID # 何か表示されたら → すぐにunset unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY -
古いCDKやSDKが
aws loginを認識しない
→ AWSが順次修正中。とりあえずアップデートするか、credential_processを使用。 -
セッションが12時間で期限切れ
→aws loginを再実行すれば完了。パニックにならないで。
aws login vs aws sso login – この1文だけ覚えればOK
| あなたはどのチーム? | 何を使う? |
|---|---|
| 個人開発者、小さなスタートアップ、通常のIAM Userのみ使用 | → aws login(新しい、便利、シンプル) |
| 会社でIAM Identity Centerを有効化済み(SSOポータル、Okta、Azure AD…がある) | → 従来通りaws sso loginを使用 |
この2つのコマンドは互いに置き換えられない。混同しないで!
キー漏洩を心配せず安心して眠るための最終チェックリスト
- AWS CLI >= 2.32.0
-
IAM Userに
SignInLocalDevelopmentAccessをアタッチ済み -
aws loginのテスト成功 -
~/.aws/credentialsの古いAccess Keyを削除/クリーンアップ - 環境変数があればunset
-
Gitの履歴をスキャン(
trufflehogまたはgit-secretsを使用)して誤ってコミットしたキーを削除 - もう時限爆弾がないことにホッと一息
まとめ
aws loginは、すべてのAWS開発者が10年前から持つべきだったものです。
5分のセットアップだけで:
- ローカル用のAccess Keyを二度と作成しなくて済む
- キー漏洩で$50kの請求書が来る悪夢を見なくて済む
- ウェブにログインするようにCLIにログイン。パスワード + MFAを覚えるだけ
スムーズなログインを祈っています。もうAccess Keyで泣くことがありませんように!🚀
公式リファレンス:
- https://aws.amazon.com/blogs/security/simplified-developer-access-to-aws-with-aws-login/
- https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sign-in.html
Goodbye Access Keys: Use aws login and Stop Crying Over Leaked Keys
Access Keys = A Ticking Time Bomb in Your Pocket
If you've ever used AWS, you've done this at least once:
- Create IAM User → click "Create access key"
- Copy-paste the key pair into
~/.aws/credentialsor worse, a.envfile - Pray you don't accidentally commit it
We all know how this ends:
- Accidental commit → 10 minutes later, someone's mining Bitcoin on your dime
- Keys never expire → one leak and you're crying all year
- Team of 10 = 10 key pairs to remember to revoke when someone leaves
On November 19, 2025, AWS dropped a game-changer: the aws login command – log into CLI exactly like you log into the AWS Console via browser. No Access Keys needed, for real!
How Does aws login Work? (As Simple as Logging into Gmail)
You type: aws login --profile dev
→ Browser opens the familiar AWS login page
→ Enter username/password + scan MFA like every day
→ Back to terminal → Done! Temporary credentials ready to go
This token will:
- Auto-refresh every 15 minutes (no worrying about expiration mid-work)
- Max 12 hours before you need to log in again (still better than eternal keys)
Setup in Actually 5 Minutes (Tested on My Mom's Computer)
Step 1: Update AWS CLI (Required)
aws --version
# Must be >= 2.32.0
Mac:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Linux:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
Step 2: Give IAM User Permission to "Login from Local Machine"
Two super easy ways, just pick one:
Best way (recommended):
Go to IAM → User → Attach policy directly → search and select
SignInLocalDevelopmentAccess
(AWS already created it for you, no need to write anything)
Manual way (if you like copy-paste):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"signin:AuthorizeOAuth2Access",
"signin:CreateOAuth2Token"
],
"Resource": "*"
}
]
}
Without this permission → browser will throw a 400 error and you'll scratch your head for 30 minutes. You've been warned!
Step 3: Let's Login!
aws login --profile dev
# or login to default
aws login
Done, verify it:
aws sts get-caller-identity --profile dev
See your ARN? You win!
Common "Gotchas" (And How to Escape in 10 Seconds)
-
Old Access Key overrides new token
→ Open~/.aws/credentials, comment out or delete those old key lines:# [dev] # aws_access_key_id = AKIA... # aws_secret_access_key = xxxx -
Environment variables trolling you
echo $AWS_ACCESS_KEY_ID # If anything shows up → unset immediately unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY -
Old CDK or SDK doesn't know what
aws loginis
→ AWS is gradually fixing this. For now, update or usecredential_process. -
Session expires after 12h
→ Just runaws loginagain. Don't panic.
aws login vs aws sso login – Just Remember This One Thing
| Which team are you on? | What to use? |
|---|---|
| Solo dev, small startup, only using regular IAM Users | → aws login (new, great, simple) |
| Company with IAM Identity Center enabled (SSO portal, Okta, Azure AD…) | → keep using aws sso login as before |
These two commands don't replace each other, don't get confused!
Final Checklist Before Sleeping Without Key Leak Nightmares
- AWS CLI >= 2.32.0
-
IAM User has
SignInLocalDevelopmentAccessattached -
aws logintest successful -
Old Access Keys deleted/cleaned from
~/.aws/credentials - Environment variables unset if any
-
Git history scanned (use
trufflehogorgit-secrets) to remove accidentally committed keys - Breathe easy because there's no more ticking time bomb
Conclusion
aws login is what every AWS developer should have had 10 years ago.
Just 5 minutes of setup, and you'll:
- Never create Access Keys for local again
- Stop having nightmares about $50k bills from leaked keys
- Log into CLI like logging into web, just remember password + MFA
Wishing you smooth logins and never crying over Access Keys again! 🚀
Official References: