I want to create a bucket and objects with not public access i.e it should be private using boto3 python code how can I achieve it?
s3_client = boto3.client('s3', aws_access_key_id=accessKey,
aws_secret_access_key=secretKey,
region_name=region)
s3_bucket= s3_client.create_bucket(Bucket=bucket_name)
print('bucket created')
print(s3_bucket)
bucket_name = 'bucket123'
response_public = s3_client.put_public_access_block(
Bucket=bucket_name,
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
},
)
print("pubic",response_public)
Bucket created but getting
error: in public access as 'S3' object has no attribute 'put_public_access_block'