0
0
GCPcloud~5 mins

Requester pays configuration in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes, when you share storage space in the cloud, the person who uses the data should pay for the cost. Requester pays configuration lets the owner of the storage make the user pay for the data they access.
When you share a large dataset with others but want them to pay for the download costs.
When you provide public data but want to avoid paying for all the access traffic.
When you want to control billing by making users responsible for their data usage.
When you want to prevent unexpected charges on your cloud storage bill.
When you collaborate with partners who should cover their own data access costs.
Commands
This command turns on requester pays for the bucket named example-bucket. Now, users must specify billing info to access data.
Terminal
gsutil requester-pays set on gs://example-bucket
Expected OutputExpected
Setting requester pays configuration on gs://example-bucket/... Requester pays configuration was set on gs://example-bucket/
This command checks if requester pays is enabled on the bucket example-bucket.
Terminal
gsutil requester-pays get gs://example-bucket
Expected OutputExpected
Requester Pays: Enabled
This command lists the contents of example-bucket while specifying the billing project my-billing-project to pay for the access.
Terminal
gsutil ls -u my-billing-project gs://example-bucket
Expected OutputExpected
gs://example-bucket/data1.csv gs://example-bucket/data2.csv
-u - Specifies the billing project to charge for the request
Key Concept

If you remember nothing else from this pattern, remember: enabling requester pays shifts storage access costs to the user who accesses the data.

Common Mistakes
Trying to access a requester pays bucket without specifying a billing project.
The request is denied because the system does not know who should pay for the data access.
Always use the -u flag with gsutil commands to specify your billing project when accessing requester pays buckets.
Turning on requester pays on the wrong bucket by mistake.
This causes users of that bucket to be unexpectedly charged, which can cause confusion or billing issues.
Double-check the bucket name before enabling requester pays and communicate changes to users.
Summary
Enable requester pays on a bucket with 'gsutil requester-pays set on'.
Verify the setting with 'gsutil requester-pays get'.
Access the bucket using 'gsutil' with the '-u' flag to specify the billing project.