[AWS S3] AWS Access Key Id you provided does not exist in our records error [Rails AWS EC2]

error contents

When I try to post an image (carrier wave) in the production environment (EC2), the following error occurs. スクリーンショット 2020-10-14 1.02.13.png

The AWSAccessKeyId displayed (loaded) is the old key you were using before. Since the old access key was read from the error statement, it was judged that the error occurred due to inconsistency.

TRY for error

The access key ID I was exporting in .bash_profile was certainly old. I updated it to a new access key, checked the .env file, IAM, aws configure list and confirmed that it was updated to the latest access key ID, but when I post the image I get the same error. Since Docker is used, there is no change even if old images are deleted.

local


$ aws configure list
AWS Access Key ID [None]: AKIA...(New access key)
AWS Secret Access Key [None]: KEY...(New access key)
Default region name:---
Default output format: json

Solution

Where I was at a loss

** I suddenly remembered the words of my predecessor, "If something goes wrong with EC2, restart the EC2 instance first." ** **

I thought, "Oh, this is the correct answer." Probably it won't load properly without restarting the EC2 instance. I logged out of the EC2 instance with exit, and re-login (ssh) didn't work.

** When I restarted the EC2 instance, it resolved as expected and I was able to post the image normally. ** **

Learn

With the AWS CLI, whenever you change your old key to a new one from your terminal, restart your EC2 instance!

If you get the same error as me even though the AWS access key ID etc. is the latest, please restart the EC2 instance you are using first.

Recommended Posts

[AWS S3] AWS Access Key Id you provided does not exist in our records error [Rails AWS EC2]
[AWS S3] AWS Access Key Id you provided does not exist in our records error [Rails AWS EC2]
Deleting AWS S3 Objects in Java
Renamed folders in AWS S3 (Java)
Error in ./gradlew: Symbol not found
Add if not in Set, error message if
JavaScript (vanilla) does not respond in Rails.