agent: |
DMmrPQwGHtD46gJcY69wList all Amazon S3 buckets in the AWS account.
List all Amazon S3 buckets in the AWS account.
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
This script lists all S3 buckets in the AWS account.
inputs
outputs
import boto3
# Initialize boto3 client for S3
s3_client = boto3.client('s3',
aws_access_key_id=getEnvVar('AWS_ACCESS_KEY_ID'),
aws_secret_access_key=getEnvVar('AWS_SECRET_ACCESS_KEY'),
region_name='us-east-2')
# List all S3 buckets
buckets = s3_client.list_buckets()['Buckets']
# Extract bucket names
bucket_names = [bucket['Name'] for bucket in buckets]
print("Bucket names:", bucket_names)
copied