node.js内のAWS ESインスタンスに接続し、簡単なリクエストでESクラスタにヒットする方法の例を探しています。node.jsからAWS ESインスタンスへの有効な署名付きリクエストの作成
elasticsearch node packageと、オープンソースのアドオンhttp-aws-esを使用しようとしています。
私は次のように見えるために私のAWS ESのアクセスポリシーを設定している:、私はプットを発行することができるとのいずれかのIPアドレスからまたはからのESインスタンス上の要求を取得したいと思いますので、
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account-id>:root"
},
"Action": "es:*",
"Resource": "example-domain.us-east-1.es.amazonaws.com:<account-id>:domain/*"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "example-domain.us-east-1.es.amazonaws.com:<account-id>:domain/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": "<my-ip>"
}
}
}
]
}
私のawsアカウントにリンクされているIAMユーザー。
I持っているのNode.jsでこれをしようとし、次のコード:
{ [Error: Authorization Exception]
status: 403,
displayName: 'AuthorizationException',
message: 'Authorization Exception' }
私が使用しての作業例を参照していました:現在、許可エラーを返し
var aws_access_key = 'example';
var aws_secret_key = 'key';
var es = require('elasticsearch').Client({
hosts: 'example-domain.us-east-1.es.amazonaws.com',
connectionClass: require('http-aws-es'),
amazonES: {
region: 'us-east-1',
accessKey: aws_access_key,
secretKey: aws_secret_key
}
});
es.ping({
// ping usually has a 3000ms timeout
requestTimeout: Infinity,
// undocumented params are appended to the query string
hello: "elasticsearch!"
}, function (error) {
if (error) {
console.log(error);
console.trace('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
node.jsで署名されたポリシーを使用して、aws ESインスタンス誰もが洞察力を持っていますか?