How to create s3 bucket using AWS-SDK without enabling cors for created bucket?


Access to XMLHttpRequest at '' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

asked 10 months ago217 views
1 Answer

You can create an S3 with the following code.
Cors is not set in this code.

import boto3

AWS_REGION ="ap-northeast-1"

client = boto3.client('s3',region_name=AWS_REGION)

bucket_name = "bucket_name"

response = client.create_bucket(Bucket=bucket_name,
                                CreateBucketConfiguration={'LocationConstraint': AWS_REGION})
profile picture
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions