This example demonstrates how to use the AWS SDK for JavaScript (v3) to work with Amazon Simple Storage Service (Amazon S3) object locking features. The workflow shows how to create, update, view, and modify object locks, as well as how locked objects behave regarding requests to delete and overwrite.
Amazon S3 Object Lock can help prevent Amazon S3 objects from being deleted or overwritten for a fixed amount of time or indefinitely. Object Lock can help meet regulatory requirements or protect against object changes or deletion.
- Running this code might result in charges to your AWS account. For more details, see AWS Pricing and Free Tier.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
For prerequisites, see the README in the javascriptv3
folder.
This example uses a workflow approach to demonstrate various aspects of S3 Object Locking. The workflow is divided into three stages:
- Deploy: Create buckets with different object locking configurations, populate buckets with objects, and set object lock and retention policies.
- Demo: Explore S3 locking features by listing objects, attempting to delete or overwrite locked objects, and viewing retention and legal hold settings.
- Clean: Remove object locks and retention periods, delete all objects and buckets.
node index.js -s deploy
node index.js -s demo
node index.js -s clean
⚠ Running tests might result in charges to your AWS account.
To find instructions for running these tests, see the README in the javascriptv3
folder.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0