LoginSignup
0
0

More than 3 years have passed since last update.

AWS CLIで(InvalidAccessKeyId)のエラーで詰まってた話

Posted at

悩まされたエラー文

An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.

経緯

  • AWS CLIをインストールしaws configureで初期設定をしました。
AWS Access Key ID [None]: ******
AWS Secret Access Key [None]: ******
Default region name [None]: ap-notheast-1
Default output format [None]: json
  • aws s3 lsでアクセスできるか確認したところ、アクセスできなかったため修正方法を確認(リージョン名の綴りを間違えてましたap-notheast-1ではなくap-northeast-1)このリージョン間違いが悪夢の始まり

  • 上記サイトを参考にrm -r .awsを実行

  • 再度IAMでアクセスキーを作成しコピペ、リージョン名もコピペ

  • 全部あってるはずなのにアクセスキーが無いというエラーが出る(2、3時間公式のドキュメント見たりバージョン違いかと思ってインストールし直したり…rm -r .awsとアクセスキー作成10回ほどやりました…笑)

  • aws configure listで登録されてる内容確認

% aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************3JQ7              env    
secret_key     ****************vnOS              env    
    region           ap-northeast-1      config-file    ~/.aws/config

access_keyとsecret_keyが直前に設定したものと違うことに気づく
Locationも公式のドキュメントで見たものと違うようでどこに保存されてるかわからない…
どなたかわかる方いらっしゃいましたらコメントお願いします。

今回のエラー解決?

  • 初期設定のaws configureaws configure --profile ユーザー名で作成
% aws configure --profile ユーザー名
AWS Access Key ID [None]: ******
AWS Secret Access Key [None]: ******
Default region name [None]: ap-northeast-1
Default output format [None]: json
  • aws --profile ユーザー名 s3 lsでアクセスできた!
% aws --profile ユーザー名 s3 ls
2021-03-21 13:26:25 ******
2021-03-21 13:24:15 ******
2021-03-21 13:31:26 ******
2021-03-20 14:31:04 ******

解決に至った参考資料

補足

% aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************3JQ7              env    
secret_key     ****************vnOS              env    
    region                <not set>             None    None
 % aws configure list --profile ユーザー名
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                   ユーザー名           manual    --profile
access_key     ****************FAFS shared-credentials-file    
secret_key     ****************Zf7u shared-credentials-file    
    region           ap-northeast-1      config-file    ~/.aws/config

解決後確認してみたらこのようになってました。後々解決できればと思ってます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0