Mic*_*ung 10 amazon-web-services amazon-elasticsearch aws-elasticsearch
我正在尝试在AWS上创建一个VPC控制的弹性搜索服务.问题是我在运行以下代码时不断收到错误:'ValidationException:在继续操作之前,必须启用服务链接角色以授予Amazon ES访问VPC的权限'.
const AWS = require('aws-sdk');
AWS.config.update({region:'<aws-datacenter>'});
const accessPolicies = {
Statement: [{
Effect: "Allow",
Principal: {
AWS: "*"
},
Action: "es:*",
Resource: "arn:aws:es:<dc>:<accountid>:domain/<domain-name/*"
}]
};
const params = {
DomainName: '<domain>',
/* required */
AccessPolicies: JSON.stringify(accessPolicies),
AdvancedOptions: {
EBSEnabled: "true",
VolumeType: "io1",
VolumeSize: "100",
Iops: "1000"
},
EBSOptions: {
EBSEnabled: true,
Iops: 1000,
VolumeSize: 100,
VolumeType: "io1"
},
ElasticsearchClusterConfig: {
DedicatedMasterCount: 3,
DedicatedMasterEnabled: true,
DedicatedMasterType: "m4.large.elasticsearch",
InstanceCount: 2,
InstanceType: 'm4.xlarge.elasticsearch',
ZoneAwarenessEnabled: true
},
ElasticsearchVersion: '5.5',
SnapshotOptions: {
AutomatedSnapshotStartHour: 3
},
VPCOptions: {
SubnetIds: [
'<redacted>',
'<redacted>'
],
SecurityGroupIds: [
'<redacted>'
]
}
};
const es = new AWS.ES();
es.createElasticsearchDomain(params, function (err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
} else {
console.log(JSON.stringify(data, null, 4)); // successful response
}
});
Run Code Online (Sandbox Code Playgroud)
问题是我收到此错误:ValidationException:在继续之前,您必须启用服务链接角色才能授予Amazon ES访问VPC的权限.我似乎无法弄清楚如何为弹性搜索服务创建此服务链接角色.在aws.amazon.com IAM控制台中,我无法为角色选择该服务.我相信它应该是自动创建的.
有没有人碰到这个或知道解决方法?
Osc*_*ett 25
可以使用AWS CLI创建服务链接角色.
aws iam create-service-linked-role --aws-service-name es.amazonaws.com
Run Code Online (Sandbox Code Playgroud)
Ris*_*ale 16
目前不支持使用/ 创建elasticsearch域.该服务需要特殊的服务链接角色来创建指定的网络接口.目前可以使用/ (@Oscar Barrett的答案如下).VPCaws-sdkcloudformationelasticsearchVPCconsolecli
但是,有一种解决方法可以使其工作,它描述如下:
elasticsearch具有VPC访问权限的测试域.AWSServiceRoleForAmazonElasticsearchService[注意:您无法手动或通过thr创建具有指定名称的角色console] 的服务链接角色aws-sdk或cloudformation创建elasticsearch域VPC.elasticsearch稍后删除测试域更新:在@Oscar Barrett的回答中描述了更正确的创建服务角色的方法.我想删除我的答案; 但关于实际问题的其他事实仍然更具相关性,因此在此保留我的答案.
hta*_*ess 12
对于遇到此错误的 terraform 用户,您可以使用aws_iam_service_linked_role资源为 ES 服务创建服务链接角色:
resource "aws_iam_service_linked_role" "es" {
aws_service_name = "es.amazonaws.com"
description = "Allows Amazon ES to manage AWS resources for a domain on your behalf."
}
Run Code Online (Sandbox Code Playgroud)
此资源是在AWS 提供商的1.15.0 版(2018 年 4 月 18 日)中添加的。
小智 7
现在,您可以在CloudFormation模板中创建与服务相关的角色,类似于@htaccess的Terraform答案。有关更多详细信息,请参阅有关服务链接角色的CloudFormation语法的文档。
YourRoleNameHere:
Type: 'AWS::IAM::ServiceLinkedRole'
Properties:
AWSServiceName: es.amazonaws.com
Description: 'Role for ES to access resources in my VPC'
Run Code Online (Sandbox Code Playgroud)
在CDK中自己做:
const serviceLinkedRole = new cdk.CfnResource(this, "es-service-linked-role", {
type: "AWS::IAM::ServiceLinkedRole",
properties: {
AWSServiceName: "es.amazonaws.com",
Description: "Role for ES to access resources in my VPC"
}
});
const esDomain = new es.CfnDomain(this, "es", { ... });
esDomain.node.addDependency(serviceLinkedRole);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5172 次 |
| 最近记录: |