Jump to Content

New API Documentation - Developer Preview Available

We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.

Class DeleteBucketPolicyCommandProtected

This implementation of the DELETE action uses the policy subresource to delete the policy of a specified bucket. If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must have the DeleteBucketPolicy permissions on the specified bucket and belong to the bucket owner's account to use this operation.

If you don't have DeleteBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a 405 Method Not Allowed error.

To ensure that bucket owners don't inadvertently lock themselves out of their own buckets, the root principal in a bucket owner's Amazon Web Services account can perform the GetBucketPolicy, PutBucketPolicy, and DeleteBucketPolicy API actions, even if their bucket policy explicitly denies the root principal's access. Bucket owner root principals can only be blocked from performing these API actions by VPC endpoint policies and Amazon Web Services Organizations policies.

For more information about bucket policies, see Using Bucket Policies and UserPolicies.

The following operations are related to DeleteBucketPolicy

Example

Use a bare-bones client and the command you need to make an API call.

import { S3Client, DeleteBucketPolicyCommand } from "@aws-sdk/client-s3"; // ES Modules import
// const { S3Client, DeleteBucketPolicyCommand } = require("@aws-sdk/client-s3"); // CommonJS import
const client = new S3Client(config);
const input = { // DeleteBucketPolicyRequest
Bucket: "STRING_VALUE", // required
ExpectedBucketOwner: "STRING_VALUE",
};
const command = new DeleteBucketPolicyCommand(input);
const response = await client.send(command);
// {};

Param

DeleteBucketPolicyCommandInput

Returns

DeleteBucketPolicyCommandOutput

See

Throws

S3ServiceException

Base exception class for all service exceptions from S3 service.

Example

To delete bucket policy

// The following example deletes bucket policy on the specified bucket.
const input = {
"Bucket": "examplebucket"
};
const command = new DeleteBucketPolicyCommand(input);
await client.send(command);
// example id: to-delete-bucket-policy-1483043406577

Hierarchy

Constructors

Properties

Methods