我目前正在从事Web项目。我们正在尝试使用 flex 搜索。当前在Amazon上托管的所有Web项目和其他工具。
我们只是为 flex 搜索,Log Stash和kibana创建一个EC2实例。之后,我们配置了 flex 搜索。我们已经成功地将 flex 搜索用于我们的目的。
但是,通过 flex 搜索和我们的Web API进行通信存在一种问题。
我们的服务器会自动扩展,因此我们为IP安全配置了 flex 搜索,如下所示。
因此,由于自动缩放,我们目前令人窒息。 IP会不时更改。我们如何配置我们的Elastic Search以从Web API服务器使用?这种情况下的最佳做法是什么?
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "arn:aws:es:eu-west:1111111111:domain/xx-log/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"1.1.1.1",
"1.1.1.2",
"1.1.1.3",
...
]
}
}
}
]
}
最佳答案
最好的选择是创建一个IAM角色,然后在启动配置中将该角色设置为“IAM角色”。 http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html
然后,使用允许AWS角色和某些特定IP访问您的Elasticsearch域的策略。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::ACCOUNTNUMBER:role/ROLENAME"
},
"Action": [
"es:ESHttpGet",
"es:ESHttpHead",
"es:ESHttpPost",
"es:ESHttpPut"
],
"Resource": "arn:aws:es:ca-central-1:ACCOUNTNUMBER:domain/ELASTICSEARCHDOMAINNAME/*"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"es:ESHttpGet",
"es:ESHttpHead",
"es:ESHttpPost",
"es:ESHttpPut"
],
"Resource": "arn:aws:es:ca-central-1:ACCOUNTNUMBER:domain/ELASTICSEARCHDOMAINNAME/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": "IPADDRESSHERE"
}
}
}
]
}
关于amazon-web-services - 保护AWS Elasticsearch最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44537801/