错误的请求签名。 AWS ElasticSearch

时间:2018-10-02 11:49:48

标签: spring amazon-web-services spring-boot elasticsearch jest

当我想从索引中删除项目时,它失败并向我们显示错误的下一条轨迹:

  

org.springframework.data.elasticsearch.ElasticsearchException:无法执行笑话动作,   响应码:403,错误:403禁止,   消息:我们计算出的请求签名与您提供的签名不匹配。   检查您的AWS Secret Access密钥和签名方法。有关详细信息,请查阅服务文档。

我已经在ElasticsearchRepository存储库中创建了一个“ removeBy ...”方法来从索引中删除项目:

public interface IndexSynonymRepository extends ElasticsearchRepository<IdxSynonym, Long> {
    void removeByIdDashboardAndIdTable(Long idDashBoard, Long idTable);
}

合并到我的JAVA项目中的版本如下: POM配置版本:

<!-- Spring Data Jest ElasticSearch AWS -->
<dependency>
    <groupId>com.github.vanroy</groupId>
    <artifactId>spring-boot-starter-data-jest</artifactId>
    <version>2.3.1.RELEASE</version>
</dependency>

<!-- Spring Data ElasticSearch -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-elasticsearch</artifactId>
    <version>2.1.1.RELEASE</version>
</dependency>

<!-- Jest -->
<dependency>
    <groupId>io.searchbox</groupId>
    <artifactId>jest</artifactId>
    <version>2.0.4</version>
</dependency>

<!-- ElasticSearch -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>2.4.4</version>
</dependency>

<!-- Spring Boot -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath />
    <!-- lookup parent from repository -->
</parent>

<!-- Aws Signing Request Interceptor -->
<dependency>
    <groupId>vc.inreach.aws</groupId>
    <artifactId>aws-signing-request-interceptor</artifactId>
    <version>0.0.20</version>
    <scope>compile</scope>
    <exclusions>
      <exclusion>
          <artifactId>*</artifactId>
          <groupId>com.amazonaws</groupId>
      </exclusion>
    </exclusions>
</dependency>

我们在AWS中配置的角色策略如下:

Access Policy ElasticSearch:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "es:*", "Resource": [ "arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/my-domain/*", "arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/my-domain" ] } ] }

EC2 Role Policy:

{ "Version": "2012-10-17", "Statement": [ { "Action": [ "es:*" ], "Resource": [ "arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/my-domain", "arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/my-domain/*" ], "Effect": "Allow" } ] }

我不知道这是否是许可证问题,或者我在签署申请时犯了一个错误。

我需要帮助来解决此问题。预先非常感谢。

1 个答案:

答案 0 :(得分:1)

配置了VPC访问权限后,使用ES访问策略模板时不需要aws-signing-request-interceptor:

enter image description here

您可以配置通过ES安全组的访问。您应该添加这样的入站规则:

Type: HTTPS
Protocol: TCP
Port: 443
Source: sg-abcdefghijklmno (Your EC2 instance Security group)

希望这会有所帮助