Amazon s3 AWS S3存储桶写入错误

Amazon s3 AWS S3存储桶写入错误,amazon-s3,amazon-sagemaker,Amazon S3,Amazon Sagemaker,我创建了AWSS3 bucket,并在Jupyter笔记本上尝试了示例kmeans示例。 作为帐户所有者,我有读/写权限,但无法写入日志,出现以下错误: ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied 这是kmeans示例代码 from sagemaker import get_execution_role role = get_execut

我创建了AWSS3 bucket,并在Jupyter笔记本上尝试了示例kmeans示例。 作为帐户所有者,我有读/写权限,但无法写入日志,出现以下错误:

 ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
这是kmeans示例代码

 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]))

即使您拥有对bucket的所有访问权限,您也需要提供访问密钥和密码,以便在bucket中放入一些私有对象。或者,若您将bucket访问公开给所有人,那个么您可以毫无问题地将对象推送到bucket