- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
GetBucketPolicyStatusCommand
This operation is not supported for directory buckets.
Retrieves the policy status for an Amazon S3 bucket, indicating whether the bucket is public. In order to use this operation, you must have the s3:GetBucketPolicyStatus
permission. For more information about Amazon S3 permissions, see Specifying Permissions in a Policy .
For more information about when Amazon S3 considers a bucket public, see The Meaning of "Public" .
The following operations are related to GetBucketPolicyStatus
:
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { S3Client, GetBucketPolicyStatusCommand } from "@aws-sdk/client-s3"; // ES Modules import
// const { S3Client, GetBucketPolicyStatusCommand } = require("@aws-sdk/client-s3"); // CommonJS import
const client = new S3Client(config);
const input = { // GetBucketPolicyStatusRequest
Bucket: "STRING_VALUE", // required
ExpectedBucketOwner: "STRING_VALUE",
};
const command = new GetBucketPolicyStatusCommand(input);
const response = await client.send(command);
// { // GetBucketPolicyStatusOutput
// PolicyStatus: { // PolicyStatus
// IsPublic: true || false,
// },
// };
GetBucketPolicyStatusCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Bucket Required | string | undefined | The name of the Amazon S3 bucket whose policy status you want to retrieve. Note: To supply the Multi-region Access Point (MRAP) to Bucket, you need to install the "aws-sdk/signature-v4-crt" package to your project dependencies. For more information, please go to https://github.com/aws/aws-sdk-js-v3#known-issues |
ExpectedBucketOwner | string | undefined | The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code |
GetBucketPolicyStatusCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
PolicyStatus | PolicyStatus | undefined | The policy status for the specified bucket. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
S3ServiceException | Base exception class for all service exceptions from S3 service. |