Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for requester-pays buckets #797

Closed
rclark opened this issue May 30, 2014 · 20 comments
Closed

Support for requester-pays buckets #797

rclark opened this issue May 30, 2014 · 20 comments
Labels
feature-request A feature should be added or improved. s3

Comments

@rclark
Copy link

rclark commented May 30, 2014

If a bucket is marked as a requester-pays bucket, then GetObject requests must specify the following header:

x-amz-request-payer: requester

There's no mention anywhere of how I might set this header using aws s3 cp or aws s3api get-object. Is it supported? Is there maybe a workaround in some fashion similar to aws/aws-sdk-js#100 (comment)?

@johnmu
Copy link

johnmu commented Jan 12, 2015

Any idea when this will be supported?

@chutium
Copy link

chutium commented Feb 11, 2015

ping again, @jamesls there is a patch for s3cmd http://arxiv.org/help/faq/bulk_data_s3_patch.txt, i tried to find similar code related to headers in awscli/customizations/s3 , but i got nothing.

@jamesls
Copy link
Member

jamesls commented Mar 24, 2015

This is now available in the 1.7.16 release of the AWS CLI. There's the control plane operations for configuring request payers on a bucket, and the various operation on an S3 object now have a --request-payer option you can provide.

@jamesls jamesls closed this as completed Mar 24, 2015
@jure
Copy link

jure commented Mar 26, 2015

How about some documentation about this feature? "--request-payer" is not an option, as far as I can tell, and I can't find what the actual option is.

@jamesls
Copy link
Member

jamesls commented Mar 26, 2015

@jure It should be documented on the various operations that support --request-payer, for example: http://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html#options shows:

--request-payer (string) Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

@jure
Copy link

jure commented Mar 27, 2015

I see, thank you @jamesls. I was trying to use aws s3 (which doens't have that option) instead of aws s3api (which does).

@eparejatobes
Copy link

@jamesls just to confirm, one is supposed to do something like

aws s3api get-object --request-payer requester --bucket <bucket> --key <key> <outfile>

@willywutang
Copy link

I also am confused about how to use this despite the comments above.

@jamesls
Copy link
Member

jamesls commented Jun 24, 2015

That's correct that you would specify --request-payer requester using a command such as aws s3api get-object.

@danielecook
Copy link

Why isn't this part of aws s3? It is very hard to find information on this fundamental feature.

@jdellithorpe
Copy link

It looks like aws s3 ls has the --request-payer option, but other subcommands like sync do not. According to my understanding, s3 uses s3api to execute its commands, so adding this functionality would simply be a matter of passing along the argument.

@jdellithorpe
Copy link

jdellithorpe commented Oct 18, 2017

For anyone else wanting to use aws s3 sync on a "Requester Pays" bucket...

aws s3 sync src dest --request-payer

With following changes made on awscli-1.11.172:

diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py
index 4637dd8..88d9d92 100644
--- a/awscli/customizations/s3/subcommands.py
+++ b/awscli/customizations/s3/subcommands.py
@@ -434,7 +434,8 @@ TRANSFER_ARGS = [DRYRUN, QUIET, INCLUDE, EXCLUDE, ACL,
                  WEBSITE_REDIRECT, CONTENT_TYPE, CACHE_CONTROL,
                  CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE,
                  EXPIRES, SOURCE_REGION, ONLY_SHOW_ERRORS, NO_PROGRESS,
-                 PAGE_SIZE, IGNORE_GLACIER_WARNINGS, FORCE_GLACIER_TRANSFER]
+                 PAGE_SIZE, IGNORE_GLACIER_WARNINGS, FORCE_GLACIER_TRANSFER,
+                 REQUEST_PAYER]
 
 
 def get_client(session, region, endpoint_url, verify, config=None):
diff --git a/awscli/customizations/s3/utils.py b/awscli/customizations/s3/utils.py
index 9d3e491..6f725a3 100644
--- a/awscli/customizations/s3/utils.py
+++ b/awscli/customizations/s3/utils.py
@@ -363,6 +363,7 @@ class BucketLister(object):
             kwargs['Prefix'] = prefix
 
         paginator = self._client.get_paginator('list_objects')
+        kwargs['RequestPayer'] = 'requester'
         pages = paginator.paginate(**kwargs)
         for page in pages:
             contents = page.get('Contents', [])
@@ -428,6 +429,7 @@ class RequestParamsMapper(object):
     @classmethod
     def map_get_object_params(cls, request_params, cli_params):
         """Map CLI params to GetObject request params"""
+        cls._set_request_payer_params(request_params, cli_params)
         cls._set_sse_c_request_params(request_params, cli_params)
 
     @classmethod
@@ -512,6 +514,11 @@ class RequestParamsMapper(object):
                          'read|readacl|writeacl|full')
 
     @classmethod
+    def _set_request_payer_params(cls, request_params, cli_params):
+        if cli_params.get('request_payer'):
+            request_params['RequestPayer'] = cli_params['request_payer']
+
+    @classmethod
     def _set_metadata_params(cls, request_params, cli_params):
         if cli_params.get('metadata'):
             request_params['Metadata'] = cli_params['metadata']

FYI this is hack, don't use long-term...

@yonist
Copy link

yonist commented Nov 30, 2017

@jdellithorpe
I applied your patch and I get the following error when running the sync command:
"an error occurred (AccessDenied) when calling the CopyObject operation: Access Denied"

It works perfectly without request-payer enabled on the bucket.
Any ideas?

Thanks.

@maheshbc
Copy link

@jdellithorpe : I have aws cli version 1.14.36

aws --version
aws-cli/1.14.36 Python/2.7.13 Darwin/15.6.0 botocore/1.8.40

I tried s3 sync with requester pays option

aws --profile s3 sync --request-payer

It says Unknown options: --request-payer

Any idea why?

@JiaweiZhuang
Copy link

It says Unknown options: --request-payer

Any idea why?

I had the same issue before. Updating awscli fixed it. --request-payer is an option in 1.14.42.

$pip install --upgrade awscli
$aws --version
aws-cli/1.14.42 Python/3.6.2 Darwin/16.7.0 botocore/1.8.46

@kyleknap
Copy link
Contributor

Yep. We just added support for --request-payer for the cp, mv, sync, and rm commands in 1.14.42. Upgrade to that version to start using it.

@maheshbc
Copy link

maheshbc commented Feb 20, 2018 via email

@Brett55
Copy link

Brett55 commented Sep 10, 2018

I'm still not seeing the request-payer argument

aws-cli/1.16.10 Python/2.7.15 Darwin/16.7.0 botocore/1.12.0

@maheshbc
Copy link

maheshbc commented Sep 10, 2018 via email

@Brett55
Copy link

Brett55 commented Sep 10, 2018

I can get aws s3 ls to work with the --request-payer argument but not aws s3 cp. aws s3 sync also works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. s3
Projects
None yet
Development

No branches or pull requests