# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 # snippet-start:[python.example_code.s3.Hello] 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() # snippet-end:[python.example_code.s3.Hello]