AWS Developer Blog

The AWS SDK for JavaScript now supports Amazon S3 Requester Pays buckets

The AWS SDK for JavaScript now has support for Amazon S3 Requester Pays buckets.

With Requester Pays buckets, the requester instead of the bucket owner pays the cost of the request and the data download from the bucket. The bucket owner always pays the cost of storing data. This allows bucket owners to share the operational cost of their buckets.

Support for Requester Pays buckets was recently added in version 2.1.19 of the SDK. This article describes how to use Requester Pays buckets with the AWS SDK for JavaScript.

Setting up a Requester Pays bucket

The easiest way to setup a Requester Pays bucket is to use the Amazon S3 console.

You can also configure a Requester Pays bucket programmatically using the SDK.

var AWS = require('aws-sdk');
var s3 = new AWS.S3({region: 'us-west-2'});

var callback = function(err, data) {
    if (err) console.log(err);
    else console.log(data);

    Bucket: 'bucket',
    RequestPaymentConfiguration: {
        Payer: 'Requester'
}, callback);

Accessing objects in Requester Pays buckets

To access objects in Requester Pays buckets, requests made using the SDK must include the RequestPayer parameter. This parameter is translated by the SDK to the x-amz-request-payer header.

Setting this parameter confirms that the requester knows that they will be charged for the request.


var s3 = new AWS.S3({region: 'us-west-2'});

    Bucket: 'bucket',
    Key: 'key',
    RequestPayer: 'requester'   
}, callback);

The only valid value for the RequestPayer parameter is requester. If the RequestPayer parameter is not set for a request made on a Requester Pays bucket, then Amazon S3 returns a 403 error and the bucket owner is charged for the request.


The AWS SDK for JavaScript supports Requester Pays for all operations on objects. We hope this feature in the SDK allows you to more easily manage your bucket permissions and cost. We’re eager to know what you think, so leave us a comment or tweet about it @awsforjs.