2017-06-26 64 views
3

私はチュートリアルhttp://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.htmlに従っています。私は奇妙な権限を持つIAMユーザーとS3バケットを設定し、サンプルのAthenaテーブルを照会でき、出力はS3バケットに書き込まれました。 これで、クライアントからAthenaテーブルにアクセスするための資格情報が得られました。これはうまくいかず、次のエラーが発生します。アクセス許可がすべて許可されていても、S3バケットへのアクセスは拒否されました

Access denied when writing output to url: s3://my-test-bucket/b36-f3c0-482-a225-34d63d355.txt . Please ensure you are allowed to access the S3 bucket. If you are encrypting query results with KMS key, please ensure you are allowed to access your KMS key

私のS3バケットは公開されているものと同じです。 「すべての認証済みAWSユーザー」の権限:読み取り、書き込み。 "everyone"の権限:読み取り、書き込み。 "ログ配布"の権限:読み取り、書き込み。 すべてのアクセス権アクセス:読み取り、書き込み

バケットポリシーは誰でもすべてを行うことができます。

{ 
"Version": "2012-10-17", 
"Statement": [ 
    { 
     "Effect": "Allow", 
     "Principal": "*", 
     "Action": "s3:ListBucket", 
     "Resource": "arn:aws:s3:::my-test-bucket" 
    }, 
    { 
     "Effect": "Allow", 
     "Principal": "*", 
     "Action": [ 
      "s3:PutObject", 
      "s3:GetObject", 
      "s3:DeleteObject" 
     ], 
     "Resource": "arn:aws:s3:::my-test-bucket/*" 
    }, 
    { 
     "Sid": "AddPerm", 
     "Effect": "Allow", 
     "Principal": "*", 
     "Action": [ 
      "s3:GetObject", 
      "s3:PutObject" 
     ], 
     "Resource": "arn:aws:s3:::my-test-bucket/*" 
    } 
] } 

CORS構成:それでも

<?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration 
xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> 
    <AllowedOrigin>*</AllowedOrigin> 
    <AllowedMethod>PUT</AllowedMethod> 
    <AllowedMethod>POST</AllowedMethod> 
    <AllowedMethod>DELETE</AllowedMethod> 
    <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> 

、私はエラーを取得:アクセスが拒否されたURLへの出力を書き込むとき...

編集を:時々私の代わりに他のエラーが出ます: "出力バケットmy-test-bucketの確認/作成ができません"。どうして私は違うエラーが出るのか分かりません。

どうすればよいですか?

答えて

0

s3の特定のファイルとほぼ同じ問題がありました。私はファイルを読むことができませんでした。 mvコマンドと--acl引数を使用して、ファイルのアクセス許可を変更して問題を解決しました。 data.jsonlinesというファイルにアクセスしようとすると、ACCESS DENIEDエラーが発生しました。

注:以下のコマンドを実行して、それを解決しようあなたが持っている必要がありますAWS CLIインストール:$ pip install --upgrade --user awscli

aws s3 cp s3://<s3 bucket name>/path/to/file/data.jsonlines s3://cfa-opengazettes-ke/gazettes/data_copy.jsonlines 

aws s3 mv --acl public-read s3://<s3 bucket name>/path/to/file/data_copy.jsonlines s3://cfa-opengazettes-ke/gazettes/data.jsonlines 

それとも、実行してそれらを組み合わせることができます。

aws s3 cp s3://<s3 bucket name>/path/to/file/data_out.jsonlines s3://cfa-opengazettes-ke/gazettes/data_out2.jsonlines && aws s3 mv --acl public-read s3://cfa-opengazettes-ke/gazettes/data_out2.jsonlines s3://<s3 bucket name>/path/to/file/data_out.jsonlines 

これらのコマンドを以下の手順を実行してください:

  • コピー:s3://<s3 bucket name>/path/to/file/data.jsonlines

  • s3://c<s3 bucket name>/path/to/file/data_copy.jsonlines への移動:s3://<s3 bucket name>/path/to/file/data_copy.jsonlines

  • s3://cfa-opengazettes-ke/path/to/file/data.jsonlines

は基本的には、ファイルのコピーを作成し、ファイルのアクセス権を変更しながら移動中にそれを削除します。

--aclオプションと引数public-readに注意してください。おそらく以下の権限のいずれかがあなたのために働く可能性があります。 public-readを別の許可に置き換えることができます。documentationから:

--acl (string) Sets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control and log-delivery-write.

このAWS page

でいくつかのより多くの有用な情報
関連する問題