"aws s3 cp" gets error while "aws s3 ls" works? - amazon-web-services

Our client shared a S3 bucket to us. The following command to list the objects works.
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... aws s3 ls s3://bucket/company4/obj1
But it got 403 error when downloading?
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... aws s3 cp s3://bucket/company4/obj1 .
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
The issue was caused by missing proxy. It works after setting the proxy export http_proxy=.... Why aws s3 ls doesn't require proxy?

Related

AWS CLI command to copy files from s3 to local machine fails with InvalidAccessKeyId

Hi folks I am following a tutorial on the AWS platform and I am stuck at a point where I have to copy some files from an s3 to local machine. I used the following command to do that:
aws s3 cp s3://wildrydes-us-east-1/WebApplication/1_StaticWebHosting/website ./ --recursive
However what I get is an error:
fatal error: An error occurred (InvalidAccessKeyId) when calling the ListObjectsV2 operation: The AWS Access Key Id you provided does not exist in our records.

Cant copy from requester pays bucket to my own bucket using the s3 module of aws cli, while I can copy to my machine fine

aws s3 cp s3://arxiv/pdf/arXiv_pdf_0001_001.tar s3://bucket --request-payer requester
fails with
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
But if I do
aws s3 cp s3://arxiv/pdf/arXiv_pdf_0001_001.tar . --request-payer requester
it works fine
Additionally this also works, but it only copies one file at a time:
aws s3api copy-object --copy-source arxiv/pdf/arXiv_pdf_0001_001.tar --request-payer requester --key arXiv_pdf_0001_001.tar --bucket arxivmanifest
Whats going on?
When I ran the first command, it gave the error:
An error occurred (AccessDenied) when calling the GetObjectTagging operation: Access Denied
This is because the aws s3 cp command does more than just copy the file by also attempting to copy tagging (it seems). It would also seem that the bucket has not granted permissions for the GetObjectTagging API call.
In contrast, the aws s3api copy-object command issues a single API call. In fact, all s3api commands map to a specific API call. The aws s3 commands are 'higher level' commands that do more, such as enabling a --recursive copy).

Unable to delete Amazon S3 Bucket

Please help to delete s3 bucket.
I have created Kubernetes Cluster during cluster build created S3 bucket, after deleting cluster unable to delete S3 bucket.
when tried to delete from S3 console getting Unknown Error (An unexpected error occurred).
Tried to delete by aws s3 rb s3://<bucket name> --force getting below error
fatal error: An error occurred (NoSuchBucket) when calling the ListObjects operation: The specified bucket does not exist
Tried to run aws s3 rm s3://<bucket name>/foo*
But no luck in resolving the issue could you please help to me to resove the issue.

AWS S3 CLI with Transfer Acceleration Download command throws 400 error : when calling the HeadObject operation: Bad Request

I am trying to upload/download to S3 with transfer acceleration endpoint in AWS CLI from an EC2.
aws s3 cp /home/centos/<FOLDER_NAME> s3://<BUCKET_NAME>/<KEY_NAME> --region
ap-south-1 --endpoint-url http://<S3-Transfer-Acc-endpoint> [--recursive]
I am able to upload files and folders successfully and also the download using recursive for folders works.
But when i download a single large file from the bucket, using the following command
aws s3 cp s3://<BUCKET_NAME>/<KEY_NAME> /home/centos/<KEY_NAME> --region
ap-south-1 --endpoint-url http://<S3-Transfer-Acc-endpoint>
I face the below issue
fatal error: An error occurred (400) when calling the HeadObject operation:
Bad Request

aws cli s3 bucket download command error

After using aws configure to setup access I can list all the files in an s3 bucket with:
aws s3api list-objects --bucket my_bucket_name
but when I run:
aws s3 cp s3://s3.amazonaws.com/my_bucket_name/ . --recursive
or
aws s3 sync s3://s3.amazonaws.com/my_bucket_name/ .
I get the following error:
fatal error: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied
Any ideas?
The following worked - ie without amazon domain:
aws s3 sync s3://my_bucket_name .