Skip to main content

GetBucketPolicy

Returns the policy of a specified bucket in JSON format.

Description

The GetBucketPolicy operation returns the policy of the specified bucket. If you are using an identity other than the root user of the account that owns the bucket, the calling identity must have the s3:GetBucketPolicy permissions on the specified bucket and belong to the bucket owner's account.

note
  • To use this operation, you must have permission to perform the s3:GetBucketPolicy action.
  • You must be the bucket owner to use this operation.
  • If there is no policy on the bucket, QStorage returns a NoSuchBucketPolicy error.

Request Syntax

GET /?policy HTTP/1.1
Host: BucketName.qstorage.quilibrium.com
x-amz-expected-bucket-owner: OwnerAccountId
Values in italics indicate user input and should be replaced with actual values.

This operation does not have a request body.

Request Parameters

Headers

NameDescriptionRequiredType
x-amz-expected-bucket-ownerThe account ID of the expected bucket ownerNotext

Examples

Example 1: Get bucket policy

GET /?policy HTTP/1.1
Host: my-bucket.qstorage.quilibrium.com
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
x-amz-id-2: Example7qoYGN7uMuFuYS6m7a4l
x-amz-request-id: TX234S0F24A06C7
Date: Wed, 01 Mar 2024 12:00:00 GMT
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-bucket/*" } ] }
Values in italics indicate variable response values.

Response Syntax

HTTP/1.1 200 OK
x-amz-id-2: RequestId
x-amz-request-id: AmazonRequestId
Date: ISO8601Date
{ "Version": "Version", "Statement": [ { "Sid": "StatementId", "Effect": "Effect", "Principal": "Principal", "Action": "Action", "Resource": "Resource", "Condition": { "ConditionOperator": { "ConditionKey": "ConditionValue" } } } ] }
Values in italics indicate variable response values.

Response Elements

Response Headers

NameDescriptionRequiredType
x-amz-id-2An identifier for the requestNoString
x-amz-request-idA unique identifier for the requestNoString
DateThe date and time at which the response was sentNoString

Response Body Elements

NameDescriptionRequiredType
PolicyThe bucket's Policy in JSON format. See BucketPolicy for details.NoString

Special Errors

Error CodeDescription
NoSuchBucketThe specified bucket does not exist
NoSuchBucketPolicyThe specified bucket does not have a bucket policy
403Forbidden. Authentication failed or you do not have permission to get the bucket policy

Permissions

You must have the s3:GetBucketPolicy permission.

Try It Out

Test GetBucketPolicy

Get the policy of a bucket.

Coming Soon

This feature is currently under development and will be available soon.