AWS SDK for .NET Documentation
GetBucketPolicy Method (request)
AmazonAmazon.S3AmazonS3ClientGetBucketPolicy(GetBucketPolicyRequest) Did this page help you?   Yes   No    Tell us about it...
Retrieves the policy for a specified bucket.
Declaration Syntax
public GetBucketPolicyResponse GetBucketPolicy(
	GetBucketPolicyRequest request
request (GetBucketPolicyRequest)
The GetBucketPolicyRequest that defines the parameters of the operation.
Return Value
Returns a GetBucketPolicyResponse from S3.

Only the owner of the bucket can retrieve the policy. If no policy has been set for the bucket, then an error will be thrown.

Bucket policies provide access control management at the bucket level for both the bucket resource and contained object resources. Only one policy can be specified per-bucket.

For more information on forming bucket polices, see:


This example shows how to Get, Put and Delete bucket policies.

CopyBucketPolicy samples
                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Put sample bucket policy (overwrite an existing policy)
                string newPolicy = @"{ 
    ""Principal"": { ""AWS"": ""*"" }, 
                PutBucketPolicyRequest putRequest = new PutBucketPolicyRequest
                    BucketName = "SampleBucket",
                    Policy = newPolicy

                // Retrieve current policy
                GetBucketPolicyRequest getRequest = new GetBucketPolicyRequest
                    BucketName = "SampleBucket"
                string policy = client.GetBucketPolicy(getRequest).Policy;


                // Delete current policy
                DeleteBucketPolicyRequest deleteRequest = new DeleteBucketPolicyRequest
                    BucketName = "SampleBucket"

                // Retrieve current policy and verify that it is null
                policy = client.GetBucketPolicy(getRequest).Policy;
                Debug.Assert(policy == null);*/

Assembly: AWSSDK (Module: AWSSDK) Version: (