LoginSignup
9
5

More than 5 years have passed since last update.

aws-cliがいきなり"AuthFailure"となった件

Last updated at Posted at 2018-06-11

発生したエラー

[nkym@localhost ~]$ aws ec2 describe-instances

An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials

原因特定までの道のり

1.aws configureを叩いてキーを確認
問題なし。

2.IAM確認
問題なし。

3.aws --debug ec2 describe-instancesを叩いてデバッグ

[nkym@localhost ~]$ aws --debug ec2 describe-instances

<省略>
2018-06-11 16:57:10,271 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - DEBUG - "POST / HTTP/1.1" 401 None
<省略>

http 401がでている。
このデバッグのログを調べたところ、時間がずれているとaws-cliが通らないとの情報入手(先人の方々と公式ドキュメントに感謝)。
公式ドキュメント:https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/set-time.html

4.dateコマンド叩く
ローカルPCの時刻が正しい時間から5分進んでいるのでこれが原因。

解決

以下のコマンドを叩いてntpサーバと同期して解決。

sudo ntpdate -v ntp.nict.jp

私の場合は社内のポート123が閉じられてたので社内ntpサーバを指定したが、
時刻同期がしっかりしていれば問題なく使用できた。

蛇足

ためしにsudo date -s "06/11 17:00 2018"というコマンドを時刻になった時に、
目測で合わせてあげてもaws-cliは問題なかった。
ntpサーバと同期するのが一番ではあるが気になったので。

9
5
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
9
5