[Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId


com.amazonaws.services.s3.model.AmazonS3Exception: 
The AWS Access Key Id you provided does not exist in our records. 
(Service: Amazon S3; Status Code: 403; 
Error Code: InvalidAccessKeyId; 
Request ID: 8CYN8...QX4; 
S3 Extended Request ID: /cXoTS2/Fl3Mj....2KjLCxUte4=; Proxy: null), 
S3 Extended Request ID: /cXoTS2/Fl3M....KjLCxUte4=
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1819)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1403)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1372)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)


If you are trying to access AWS S3 using the Java SDK and ProfileCredentialsProvider you get AmazonS3Exception InvalidAccessKeyId, the reason could be either of the below,


  • You have provided an invalid aws_access_key_id in your AWS profile credentials in the .aws directory,
  • The Access key must have expired,
  • Check if the access key is not enclosed by double or single quotes, it should look something like the below,

    % cat ~/.aws/credentials
    [default]
    aws_access_key_id = ABCDEYK2XYZANEEMOVA
    aws_secret_access_key = ABCDEFXyzhFNPwvctQ1X2DEK4k245aDh82a


Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap