Reputation: 45
I am creating a AWS Lambda function using Python. I want to create S3 bucket but I am getting error as the bucket name provided by me is not JSON serializable.
Here is the code I used for creating a bucket with Lambda:
import boto from boto
import s3 from boto.s3.connection
import S3Connection
def lambda_handler(event, context):
conn = S3Connection('access_key','secret_access_key')
print "Connection:",conn
bucket = conn.create_bucket('bucketname')
print bucket
return bucket
Upvotes: 4
Views: 7287
Reputation: 269091
From Creating and Using Amazon S3 Buckets boto3 documentation:
import boto3
s3 = boto3.client('s3')
s3.create_bucket(Bucket='my-bucket')
Rules for bucket names:
Upvotes: 3