amazon-web-services - 如何手动设置 AWS ElasticSearch 并通过浏览器使用 kibana?
问题描述
我一直在努力设置 AWS ES 和使用 kibana。我正在关注AWS 上的 Amazon Elasticsearch Service 文档。
当我进入第 2 步:将数据上传到 Amazon ES 域以进行索引curl -XPUT elasticsearch_domain_endpoint/movies/_doc/1 -d '{"director": "Burton, Tim", "genre": ["Comedy","Sci-Fi"], "year": 1996, "actor": ["Jack Nicholson","Pierce Brosnan","Sarah Jessica Parker"], "title": "Mars Attacks!"}' -H 'Content-Type: application/json'
时,我按照文档指示运行失败,出现{"Message":"User: anonymous is not authorized to perform: es:ESHttpPut"}
.
我将 ES 的策略设置为:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::my_id:user/my_iam_user"
},
"Action": "es:*",
"Resource": "arn:aws:es:us-west-2:my_id:domain/my-domain/*"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "arn:aws:es:us-west-2:my_id:domain/my-domain/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [my_ips]
}
}
}
]
}
我通过ifconfig | grep "inet " | grep -v 127.0.0.1
从终端调用、点击checkip.amazonaws.com
并检查 Chrome 上的 Developer Tools -> Network 获得了上面的 IP(这些是 3 个不同的 IP,我将它们全部添加)。
我还为我的 IAM 用户添加了以下角色:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"es:DescribeReservedElasticsearchInstanceOfferings",
"es:DescribeReservedElasticsearchInstances",
"es:ListDomainNames",
"es:PurchaseReservedElasticsearchInstance",
"es:DeleteElasticsearchServiceRole",
"es:ListElasticsearchInstanceTypes",
"es:DescribeElasticsearchInstanceTypeLimits",
"es:ListElasticsearchVersions"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "es:*",
"Resource": "arn:aws:es:us-west-2:my_id:domain/my-domain"
}
]
}
我已经在我的机器上设置了 AWS CLI,并且能够通过aws es describe-elasticsearch-domain --domain my-domain
.
尽管如此,我还是curl XPUT
因为同样的原因未能在上面调用并未能访问 kibana{"Message":"User: anonymous is not authorized to perform: es:ESHttpPut"}
这是我在这里提出问题之前阅读的几篇文章:
- https://aws.amazon.com/premiumsupport/knowledge-center/anonymous-not-authorized-elasticsearch/?nc1=h_ls
- https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-ac.html
- https://aws.amazon.com/cn/blogs/database/set-access-control-for-amazon-elasticsearch-service/
- Amazon Elastic Search 集群的正确访问策略
- https://aws.amazon.com/cn/blogs/security/how-to-control-access-to-your-amazon-elasticsearch-service-domain/
仍然无法让它工作。
任何人都可以指导我手动设置 AWS ES 的整个过程,并能够通过 AWS CLI 以及浏览器上的 kibana 进行操作吗?如果它可以是详细的分步指南而不是抛出 aws 文档,我将不胜感激。非常感谢。
解决方案
事实证明,我使用的 IP 不正确。我应该checkip.amazonaws.com
在不在 VPN 下的时候打电话,而且 IP 可能会改变。ES 的政策应该是这样的:Anther Answer
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::xxxxxxxxxxxx:root"
},
"Action": "es:*",
"Resource": "arn:aws:es:us-west-2:xxxxxxxxxxxx:domain/my-elasticsearch-domain/*"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "arn:aws:es:us-west-2:xxxxxxxxxxxx:domain/my-elasticsearch-domain/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"192.168.1.0",
"192.168.1.1"
]
}
}
}
]
}
*附注。确保您checkip.amazonaws.com
在同一个浏览器上调用(如果您使用的是 chrome,则也是同一个用户)
推荐阅读
- java - 无法从 ZIP 文件输入流中读取文件
- swift - 返回通用集合的迭代器 - Swift 4.2
- node.js - NodeJS 在重复函数调用上更快执行
- r - 重命名列数据
- c++ - 受彩色矩形影响的所有纹理颜色 - OpenGL
- amazon-web-services - Couchbase 控制台 - aws
- amazon-web-services - 我可以使用任何 AWS EMR 工具将数据集导出到 s3 上的 100 万个单独的 json 文件吗
- typescript - 我从手机创建了一个音频文件,但它不能使用 HTML5 播放
- infinispan - Infinispan 9 - 尝试使用 Hotrod 客户端和 Protobuf 将对象放入缓存时出现服务器异常
- c++ - 执行 Qt 应用程序时在终端中查看 C++ 输出 (macOS)