amazon-web-services - AWS Elasticsearch IAM 作为主用户获取 AuthorizationException 试图放置数据
问题描述
尝试将文档放入 AWS ES 集群。代码:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
import boto3
host = 'search-dev-operations-2-XXXXXXXX.us-east-2.es.amazonaws.com' # For example, my-test-domain.us-east-1.es.amazonaws.com
region = 'us-east-2' # e.g. us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
document = {
"title": "Moneyball",
"director": "Bennett Miller",
"year": "2011"
}
es.index(index="dev-operations-2", doc_type="_doc", id="5", body=document)
print(es.get(index="dev-operations-2", doc_type="_doc", id="5"))
收到此错误消息:
elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, '{"Message":"User: arn:aws:iam::XXXXXX:user/andrey.tantsuyev@XXXtechnology.com is not authorized to perform: es:ESHttpPut with an explicit deny"}')
arn:aws:iam::XXXXXX:user/andrey.tantsuyev@XXXtechnology.com
通过精细访问设置为 IAM 主用户。这是我的 AWS 用户
有人可以帮我吗?不知道为什么我没有被授权。
解决方案
这在 ElasticSearch 中不是问题,这是根据与您的 IAM 用户关联的策略被阻止的。
转到 IAM 服务控制台并查找andrey.tantsuyev@XXXtechnology.com
用户的权限。似乎有一个“拒绝”语句与附加到与该es:ESHttpPut
操作匹配的用户的组/策略之一相关联。
推荐阅读
- regex - Python正则表达式解析跨越多行的sudoers日志内容
- r - 来自“R 中的贝叶斯网络”一书的 gs (bnlearn) 输出的再现性
- watchkit - 如何在 watchOS6 中更改 rootInterfaceController
- c# - 如何在 Microsoft Fakes 上的通用列表上有效地绑定 IEnumerable 接口
- python-3.x - 为什么我无法使用 mechanize 登录 otter.ai
- c# - 连接到远程数据库
- ubuntu - 从 debian 包 postinstall 脚本启动 GUI 应用程序
- hive - 使用 hive 的随机样本
- java - 有没有一种方法可以在 Java 字符串中引用花括号?
- c - 如何替换一行txt文件?