我正在尝试在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
}
});
问题是我收到这个错误: ValidationException:在继续之前,您必须启用一个服务链接角色,以授予Amazon ES访问您的VPC的权限。我似乎不知道如何为elastic search服务创建这个与服务相关的角色。在aws.amazon.com IAM控制台中,我无法为角色选择该服务。我相信它应该是自动创建的。
有没有人遇到过这个问题,或者知道修复的方法?
发布于 2018-04-13 11:09:10
可以使用AWS CLI创建与服务相关的角色。
aws iam create-service-linked-role --aws-service-name es.amazonaws.com
发布于 2018-10-16 11:09:50
您现在可以在CloudFormation模板中创建一个与服务相关的角色,类似于由@htaccess提供的Terraform答案。有关详细信息,请参阅the documentation for the CloudFormation syntax for Service-Linked Roles
YourRoleNameHere:
Type: 'AWS::IAM::ServiceLinkedRole'
Properties:
AWSServiceName: es.amazonaws.com
Description: 'Role for ES to access resources in my VPC'
发布于 2017-11-29 16:51:03
当前不支持使用VPC
和aws-sdk
/cloudformation
创建elasticsearch
域。elasticsearch
服务需要特殊的服务链接角色才能在指定的VPC
中创建网络接口。这目前可以使用console
/ cli
(@Oscar Barrett的答案如下)。
但是,有一种解决方法可以使其正常工作,如下所述:
VPC
访问权限的测试elasticsearch
域将创建名为AWSServiceRoleForAmazonElasticsearchService
的服务链接角色注意:您不能手动或通过console
aws-sdk
或cloudformation
通过VPC
.elasticsearch
域以后可以删除测试elasticsearch
域<代码>H225<代码>F226更新:更正确的创建服务角色的方法在@Oscar Barrett的回答中描述。我正在考虑删除我的答案;但关于实际问题的其他事实仍然更相关,因此我的答案保留在这里。
https://stackoverflow.com/questions/47229247
复制相似问题