Repository navigation
Closed
Labels
Milestone
Description
What is the problem you are having with rclone?
rclone will not copy files to a Amazon S3 bucket with only the PutObject authorization granted to the IAM role attached to an EC2 instance.
What is your rclone version (output from rclone version)
rclone v1.52.2
Which OS you are using and how many bits (eg Windows 7, 64 bit)
os/arch: windows/amd64 : Windows 10 64 bits
Which cloud storage system are you using? (eg Google Drive)
S3
The command you were trying to run (eg rclone copy /tmp remote:tmp)
rclone.exe copy file.txt s3bucket:redactedbucketname/somefolder/file.txt --no-check-dest --no-traverse --retries 1
A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)
2020/07/20 08:57:49 DEBUG : rclone: Version "v1.52.2" starting with parameters ["rclone.exe" "copy" "file.txt" "s3bucket:redactedbucketname/somefolder/file.txt" "-vv" "--no-check-dest" "--dump" "headers" "--no-traverse" "--retries" "1"]
2020/07/20 08:57:49 DEBUG : Using config file from "C:\\Users\\Administrator\\.config\\rclone\\rclone.conf"
2020/07/20 08:57:49 DEBUG : fs cache: renaming cache item "file.txt" to be canonical "//?/C:/Users/Administrator/Downloads/rclone-current-windows-amd64/rclone-v1.52.2-windows-amd64"
2020/07/20 08:57:49 DEBUG : You have specified to dump information. Please be noted that the Accept-Encoding as shown may not be correct in the request and the response may not show Content-Encoding if the go standard libraries auto gzip encoding was in effect. In this case the body of the request will be gunzipped before showing it.
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : HTTP REQUEST (req [REDACTED])
2020/07/20 08:57:49 DEBUG : PUT /latest/api/token HTTP/1.1
Host: 169.254.169.254
User-Agent: rclone/v1.52.2
Content-Length: 0
X-Aws-Ec2-Metadata-Token-Ttl-Seconds: 21600
Accept-Encoding: gzip
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : HTTP RESPONSE (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HTTP/1.1 200 OK
Connection: close
Content-Length: 56
Content-Type: text/plain
Date: Mon, 20 Jul 2020 08:57:49 GMT
Server: EC2ws
X-Aws-Ec2-Metadata-Token-Ttl-Seconds: 21600
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : HTTP REQUEST (req [REDACTED])
2020/07/20 08:57:49 DEBUG : GET /latest/meta-data/iam/security-credentials/ HTTP/1.1
Host: 169.254.169.254
User-Agent: rclone/v1.52.2
X-Aws-Ec2-Metadata-Token: [REDACTED]
Accept-Encoding: gzip
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : HTTP RESPONSE (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HTTP/1.1 200 OK
Connection: close
Content-Length: 35
Accept-Ranges: none
Content-Type: text/plain
Date: Mon, 20 Jul 2020 08:57:49 GMT
Last-Modified: Mon, 20 Jul 2020 08:47:27 GMT
Server: EC2ws
X-Aws-Ec2-Metadata-Token-Ttl-Seconds: 21600
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : HTTP REQUEST (req [REDACTED])
2020/07/20 08:57:49 DEBUG : GET /latest/meta-data/iam/security-credentials/REDACTEDIAMROLE HTTP/1.1
Host: 169.254.169.254
User-Agent: rclone/v1.52.2
X-Aws-Ec2-Metadata-Token: [REDACTED]
Accept-Encoding: gzip
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : HTTP RESPONSE (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HTTP/1.1 200 OK
Connection: close
Content-Length: 1298
Accept-Ranges: none
Content-Type: text/plain
Date: Mon, 20 Jul 2020 08:57:49 GMT
Last-Modified: Mon, 20 Jul 2020 08:47:27 GMT
Server: EC2ws
X-Aws-Ec2-Metadata-Token-Ttl-Seconds: 21600
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : HTTP REQUEST (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HEAD /somefolder/file.txt HTTP/1.1
Host: redactedbucketname.s3.us-east-2.amazonaws.com
User-Agent: rclone/v1.52.2
Authorization: XXXX
X-Amz-Content-Sha256: [REDACTED]
X-Amz-Date: 20200720T085749Z
X-Amz-Security-Token: [REDACTED]
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : HTTP RESPONSE (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HTTP/1.1 403 Forbidden
Transfer-Encoding: chunked
Content-Type: application/xml
Date: Mon, 20 Jul 2020 08:57:49 GMT
Server: AmazonS3
X-Amz-Id-2: [REDACTED]
X-Amz-Request-Id: [REDACTED]
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : file.txt: Need to transfer - File not found at Destination
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : HTTP REQUEST (req [REDACTED])
2020/07/20 08:57:49 DEBUG : PUT / HTTP/1.1
Host: redactedbucketname.s3.us-east-2.amazonaws.com
User-Agent: rclone/v1.52.2
Content-Length: 153
Authorization: XXXX
X-Amz-Acl: private
X-Amz-Content-Sha256: [REDACTED]
X-Amz-Date: 20200720T085749Z
X-Amz-Security-Token: [REDACTED]
Accept-Encoding: gzip
2020/07/20 08:57:49 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 DEBUG : HTTP RESPONSE (req [REDACTED])
2020/07/20 08:57:49 DEBUG : HTTP/1.1 403 Forbidden
Transfer-Encoding: chunked
Content-Type: application/xml
Date: Mon, 20 Jul 2020 08:57:49 GMT
Server: AmazonS3
X-Amz-Id-2: [REDACTED]
X-Amz-Request-Id: [REDACTED]
2020/07/20 08:57:49 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2020/07/20 08:57:49 ERROR : file.txt: Failed to copy: AccessDenied: Access Denied
status code: 403, request id: [REDACTED], host id: [REDACTED]
2020/07/20 08:57:49 ERROR : Attempt 1/1 failed with 1 errors and: AccessDenied: Access Denied
status code: 403, request id: [REDACTED], host id: [REDACTED]
2020/07/20 08:57:49 INFO :
Transferred: 0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors: 1 (retrying may help)
Elapsed time: 0.0s
2020/07/20 08:57:49 DEBUG : 4 go routines active
2020/07/20 08:57:49 Failed to copy: AccessDenied: Access Denied
status code: 403, request id: [REDACTED], host id: [REDACTED]
Here is the bucket access policy :
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::redactedaccountnumber:role/REDACTEDIAMROLE"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::redactedbucketname/*"
}
]
}
The equivalent aws s3 cp file.txt s3://redactedbucketname/somefolder/file.txt works fine.
The rclone config section is as follows :
[s3bucket]
type = s3
provider = AWS
env_auth = true
region = us-east-2
Regards
Activity
ncw commentedon Jul 21, 2020
This is rclone trying to create the bucket if it doesn't exist.
This is quite a similar problem to #4297 which was fixed by 723c1df
This fix would work here too, but because you've used
--no-traverseand--no-check-existingby the time rclone comes to do the upload it doesn't know if the bucket exists or not because it hasn't listed it or anything within it.So I guess options are
--s3-assume-bucket-existsflag or something like thatThoughts?
Any other idea?
EmilienCourt commentedon Jul 21, 2020
Thanks @ncw for the answer.
I have tried with and without the
--no-traverseand--no-check-existingoptions, but it would not work either (due to the very restrictive bucket policy).The
--s3-assume-bucket-existswould be the best option, according to me.Maybe a more global switch like
--bare-requestswould also be appropriate (only forcopy) ?This would just send the PUT requests (which is what
aws s3api cpdoes). I think it would be more convenient than having to set--no-traverse,--no-check-existingand--s3-assume-bucket-exists.s3: add --s3-no-check-bucket for minimising rclone transactions and p…
ncw commentedon Jul 22, 2020
Sure
I made a
--s3-no-check-bucketflag here - can you have a go?v1.52.2-233-g5ef6948d-fix-4449-s3-no-check-bucket-beta on branch fix-4449-s3-no-check-bucket (uploaded in 15-30 mins)
However this is still doing a post copy HEAD request to check the file was uploaded correctly...
This is a bit difficult to fit into rclone's framework...
I could do a backend command for
s3sayrclone backend put s3:bucket fileor something like that which just did the put.EmilienCourt commentedon Jul 22, 2020
I've just tested the beta version you have linked, it works just fine. Thanks !
There is indeed a HEAD request before (the result of which is ignored) and after the copy. The result of the operation is "Failed", because of the latter (as you mentionned).
Regarding the backend command, I would not personally use it if implemented (as I have to copy entire folders) but it might be useful to some.
ncw commentedon Jul 27, 2020
I've merged this to master now which means it will be in the latest beta in 15-30 mins and released in v1.53
I'll leave the backend command for the moment :-)
s3: add --s3-no-check-bucket for minimising rclone transactions and p…