Reputation: 79
I am trying to upload a file from an EC2 instance to S3 bucket and get this error:
[ec2-user@zzzzzzz parsers]$ aws s3 cp file.txt s3://bucket/output/file.txt
upload failed: ./file.txt to s3://bucket/output/file.txt A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records.
I have already configured the aws configure file in EC2 as follows:
[ec2-user@zzzzz parsers]$ aws configure list
Name Value Type Location ---- ----- ---- -------- profile <not set> None None access_key ****************NTr6 config-file secret_key ****************AFJQ config-file region us-west-2 config-file ~/.aws/config
What else should I do to make this work?
Upvotes: 2
Views: 3620
Reputation: 1131
It's recommended to use IAM roles instead of IAM access keys for EC2 instances. By simply creating a IAM role to access S3 and link it to your EC2 instance, you can list, download and upload files from and to your S3 bucket(s) based on the role's policy.
It's more secure and you don't have to configure your aws credentials.
Upvotes: 0
Reputation: 270224
InvalidAccessKeyId
indicates that the Access Key and Secret Key are not valid.
Access Keys (and their corresponding Secret Keys) can be associated to either either:
It is recommended that Master credentials not be used on a daily basis. (See IAM Best Practices.)
If your credentials are associated with an IAM user, you can generate a new set of credentials:
A new Access Key and Secret Key will be displayed. Try using them in CLI configuration.
Up to two sets of Access Keys can be associated with a User at any time.
Upvotes: 3