Shahek
Shahek

Reputation: 83

AWS S3 bucket write error

I created AWS S3 bucket and tried sample kmeans example on Jupyter notebook. Being account owner I have read/write permissions but I am unable to write logs with following error,

 ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

here's the kmeans sample code,

 from sagemaker import get_execution_role
 role = get_execution_role()
 bucket='testingshk' 

 import pickle, gzip, numpy, urllib.request, json
urllib.request.urlretrieve("http://deeplearning.net/data/mnist/mnist.pkl.gz", "mnist.pkl.gz")
 with gzip.open('mnist.pkl.gz', 'rb') as f:
 train_set, valid_set, test_set = pickle.load(f, encoding='latin1')

 from sagemaker import KMeans
 data_location = 's3://{}/kmeans_highlevel_example/data'.format(bucket)
 output_location = 's3://{}/kmeans_example/output'.format(bucket)

 print('training data will be uploaded to: {}'.format(data_location))
 print('training artifacts will be uploaded to: {}'.format(output_location))

 kmeans = KMeans(role=role,
            train_instance_count=2,
            train_instance_type='ml.c4.8xlarge',
            output_path=output_location,
            k=10,
            data_location=data_location)
 kmeans.fit(kmeans.record_set(train_set[0]))

Upvotes: 0

Views: 1224

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 892

Even if you have all the access to the bucket, you need to provide access key and secret in order to put some object in bucket if it is private. Or if you make bucket access public to all then you can push object to bucket without any problem.

Upvotes: 1

Related Questions