Back to Aws Doc Sdk Examples

Amazon S3 Conditional Requests Feature Scenario for the SDK for Python (boto3)

python/example_code/s3/scenarios/conditional_requests/README.md

latest2.5 KB
Original Source

Amazon S3 Conditional Requests Feature Scenario for the SDK for Python (boto3)

Overview

This example demonstrates how to use the AWS SDK for Python (boto3) to work with Amazon Simple Storage Service (Amazon S3) conditional request features. The scenario demonstrates how to add preconditions to S3 operations, and how those operations will succeed or fail based on the conditional requests.

Amazon S3 Conditional Requests are used to add preconditions to S3 read, copy, or write requests.

⚠ 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

To run these examples, you need:

  • Python 3.x installed.
  • Run python pip install -r requirements.txt
  • AWS credentials configured. For more information, see Configuring the AWS CLI.

Scenario

This example uses a feature scenario to demonstrate various aspects of S3 conditional requests. The scenario is divided into three stages:

  1. Setup: Create test buckets and objects.
  2. Conditional Reads and Writes: Explore S3 conditional requests by listing objects, attempting to read or write with conditional requests, and viewing request results.
  3. Clean: Delete all objects and buckets.

Running the scenario

To run this feature scenario, run the command below from this directory:

python scenario.py

Additional resources


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

SPDX-License-Identifier: Apache-2.0