Requester Pays — An Easier Way to Split the Bill

Now that you’ve got the billing basics, let’s add a level of complexity!

Like when a client needs to be billed for their usage of your resources. We’ll avoid the awkward eye-contact-and-reach-for- the-wallet game, and find a clear path to splitting this bill. In this Cloud Storage Bytes post, I’m taking you into the world of Requester Pays.

Who takes the check?

Whenever a user accesses a Cloud Storage resource like a bucket or object, there are charges associated with both making and executing the request.

These charges include:

  • operation charges for performing a request
  • network charges for reading the data
  • Data retrieval if the data is stored as Nearline Storage or Coldline Storage

Normally, the project owner of the resource is billed for these access charges, but this isn’t always appropriate. If the requester provides a billing project with their request, the requester’s project is billed instead. This feature is appropriately called “Requester Pays”.

With Requester Pays enabled on your bucket, you can require requesters to include a billing project in their requests, thus billing the requester’s project.

Enabling Requester Pays is useful, for example, if you have a lot of data you want to make available to users, but you don’t want to be charged for their access to that data.

Note that there are some charges that will always be applied to the project containing the bucket, even when Requester Pays is enabled. These charges include storage charges for storing data in a bucket, and any applicable early deletion charges.

Enabling and disabling Requester Pays

Here’s how to enable Requester Pays:

  1. Start in the Cloud Storage browser in the Google Cloud Platform Console.
  2. In the list of buckets, find the bucket you want to enable, and click the Off button in the Requester pays column.

3. In the window that appears, click Turn On.

4. Once enabled, a green bubble and On appear in the Requester pays column for the bucket.

Of course, once you enable Requester Pays, you may need to disable it. Let’s walk through that process.

Here’s how to disable Requester Pays:

  1. Start in the Cloud Storage browser in the Google Cloud Platform Console.
  2. In the list of buckets, find the bucket you want to disable, and click the On button in the Requester pays column.
  3. In the window that appears, click Turn Off.

Once disabled, a gray bubble and Off appear in the Requester pays column. To check whether Requester Pays is enabled on a bucket, take a look at the list of buckets. The Requester Pays status of each bucket is found in the Requester Pays column.

Accessing an object in a Requester Pays bucket

Let’s look at accessing Requester Pays buckets using gsutil.

Here’s how to include a billing project so that you can download an object stored in a Requester Pays bucket using gsutil:

gsutil -u [PROJECT_ID] cp gs://[BUCKET_NAME]/[OBJECT_NAME] [OBJECT_DESTINATION]

[PROJECT_ID] is the ID of the project to be billed. For example, my-project.

[BUCKET_NAME] is the name of the relevant bucket. For example, my-bucket.

[OBJECT_NAME] is the name of the object you want to download. For example, pets/dog.png.

[OBJECT_DESTINATION] is the location where you want to save your object. For example, Desktop/dog.png.

Thus, the complete example looks like this:

gsutil -u my-project cp gs://my-bucket/pets/dog.png Desktop/dog.png

Keep in mind that buckets that have Requester Pays disabled still accept requests that include a billing project, and charges are applied to the billing project supplied in the request.

Remember to consider any billing implications prior to including a billing project in all of your requests.

Thanks for reading this quick byte of cloud storage — stay tuned for more!

Google Cloud Developer Advocate, Thinker, Feeler, Adventurer, Surfer, Burner. Opinions are my own, but I’m happy to share.