Code examples for Amazon S3 using AWS SDKs - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Code examples for Amazon S3 using AWS SDKs

The following code examples show how to use Amazon Simple Storage Service with an AWS software development kit (SDK).

Get started

The following code example shows how to get started using Amazon Simple Storage Service (Amazon S3).

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import boto3 def hello_s3(): """ Use the AWS SDK for Python (Boto3) to create an Amazon Simple Storage Service (Amazon S3) resource and list the buckets in your account. This example uses the default settings specified in your shared credentials and config files. """ s3_resource = boto3.resource('s3') print("Hello, Amazon S3! Let's list your buckets:") for bucket in s3_resource.buckets.all(): print(f"\t{bucket.name}") if __name__ == '__main__': hello_s3()
  • For API details, see ListBuckets in AWS SDK for Python (Boto3) API Reference.

Code examples