Skip to content

Latest commit

 

History

History

Amazon S3 Object Lock Workflow for the SDK for JavaScript (v3)

Overview

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.

⚠ Important

  • 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.

Code examples

Prerequisites

For prerequisites, see the README in the javascriptv3 folder.

Scenarios

This example uses a workflow approach to demonstrate various aspects of S3 Object Locking. The workflow is divided into three stages:

  1. Deploy: Create buckets with different object locking configurations, populate buckets with objects, and set object lock and retention policies.
  2. Demo: Explore S3 locking features by listing objects, attempting to delete or overwrite locked objects, and viewing retention and legal hold settings.
  3. Clean: Remove object locks and retention periods, delete all objects and buckets.

Deploy Stage

node index.js -s deploy

Demo Stage

node index.js -s demo

Clean Stage

node index.js -s clean

Tests

⚠ Running tests might result in charges to your AWS account.

To find instructions for running these tests, see the README in the javascriptv3 folder.

Additional resources


Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0