【问题标题】:Error the request signature. AWS ElasticSearch请求签名出错。 AWS 弹性搜索
【发布时间】:2019-03-07 13:05:43
【问题描述】:

当我想从索引中删除一个项目时,它会失败并显示下一个错误痕迹:

org.springframework.data.elasticsearch.ElasticsearchException:无法执行开玩笑动作, 响应代码:403,错误:403 Forbidden, message : 我们计算的请求签名与您提供的签名不匹配。 检查您的 AWS 秘密访问密钥和签名方法。有关详细信息,请参阅服务文档。

我在 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" } ] }

我不知道是许可证问题还是我在签署申请时出错了。

我需要帮助来解决这个问题。非常感谢您。

【问题讨论】:

  • 您好,您的集群配置为公共访问还是 VPC 访问?
  • 首先,感谢您的回答。我的集群已将其配置为通过 VPC 进行访问。对此有何建议?
  • 在与 AWS ES 连接的 Vanroy jest 配置示例中,它包含对 aws-signing-request-interceptor 的依赖项。你添加了那个依赖吗?
  • 是的,我已将它添加到我的项目中。我编辑了添加依赖项的初始问题。

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


【解决方案1】:

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

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

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

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2020-11-20
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    相关资源
    最近更新 更多