GetBucketVersioningCommand

This operation is not supported for directory buckets.

Returns the versioning state of a bucket.

To retrieve the versioning state of a bucket, you must be the bucket owner.

This implementation also returns the MFA Delete status of the versioning state. If the MFA Delete status is enabled, the bucket owner must use an authentication device to change the versioning state of the bucket.

The following operations are related to GetBucketVersioning:

Example Syntax

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

import { S3Client, GetBucketVersioningCommand } from "@aws-sdk/client-s3"; // ES Modules import
// const { S3Client, GetBucketVersioningCommand } = require("@aws-sdk/client-s3"); // CommonJS import
const client = new S3Client(config);
const input = { // GetBucketVersioningRequest
  Bucket: "STRING_VALUE", // required
  ExpectedBucketOwner: "STRING_VALUE",
};
const command = new GetBucketVersioningCommand(input);
const response = await client.send(command);
// { // GetBucketVersioningOutput
//   Status: "Enabled" || "Suspended",
//   MFADelete: "Enabled" || "Disabled",
// };

Example Usage

 Loading code editor

GetBucketVersioningCommand Input

See GetBucketVersioningCommandInput for more details

Parameter
Type
Description
Bucket
Required
string | undefined

The name of the bucket for which to get the versioning information.

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 403 Forbidden (access denied).

GetBucketVersioningCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
MFADelete
MFADeleteStatus | undefined

Specifies whether MFA delete is enabled in the bucket versioning configuration. This element is only returned if the bucket has been configured with MFA delete. If the bucket has never been so configured, this element is not returned.

Status
BucketVersioningStatus | undefined

The versioning state of the bucket.

Throws

Name
Fault
Details
S3ServiceException
Base exception class for all service exceptions from S3 service.