Ale*_*lex 5 amazon-s3 amazon-web-services amazon-athena
我按照教程http://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html进行了操作.我设置了一个IAM用户(具有奇怪的权限)和一个S3-bucket,可以查询样本Athena表,并将输出写入我的S3-bucket.现在我有来自客户端的凭据来访问他的Athena表.这不起作用,我得到以下错误:
将输出写入url:s3://my-test-bucket/b36-f3c0-482-a225-34d63d355.txt时拒绝访问.请确保您可以访问S3存储桶.如果您使用KMS密钥加密查询结果,请确保您可以访问KMS密钥
我的S3-bucket是公共的."任何经过身份验证的AWS用户"的权限:读取,写入."每个人"的权限:读,写."日志传送"的权限:读取,写入.所有内容的"权限访问":读取,写入
Bucket Policy允许每个人都做任何事情.
{
"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/*"
}
] }
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
仍然,我得到错误:将输出写入url时访问被拒绝...
编辑:我不时会收到另一个错误:"无法验证/创建输出存储桶my-test-bucket".不知道为什么我会得到不同的错误.
我能做什么?
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
Run Code Online (Sandbox Code Playgroud)
或者您可以通过运行来组合它们:
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
Run Code Online (Sandbox Code Playgroud)
这些命令执行以下步骤:
复制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为其他权限。从文档中:
--acl(字符串)执行命令时设置对象的 ACL。如果您使用此参数,您的 IAM 策略的操作列表中必须包含“s3:PutObjectAcl”权限。仅接受private、public-read、 public-read-write、authentiated-read、aws-exec-read、 bucket-owner-read、bucket-owner-full-control和log-delivery-write的值。
此AWS 页面上有一些更有用的信息
| 归档时间: |
|
| 查看次数: |
3848 次 |
| 最近记录: |