Searchkick AWS 凭证过期

Searchkick AWS Credentials Expire

我已经通过 elasticsearch.rb 初始化程序设置了以下 aws_credentials。

  Searchkick.aws_credentials = {
    credentials: Aws::InstanceProfileCredentials.new.credentials,
    region: 'us-west-2',
  }

这在我第一次重新部署时工作正常,但在 12 小时后,我的凭据过期并且我最终遇到了一堆错误:

Elasticsearch::Transport::Transport::Errors::Forbidden ([403] {"message":"The security token included in the request is expired"})

考虑到我的一组凭证的有效期似乎是 12 小时,这是有道理的。 Aws::InstanceProfileCredentials.new.expiration = 2020-02-13 21:36:30 UTC

鉴于我想继续轮换凭据,我如何让 Searchkick 为每个请求提取最新的凭据?

通过整个 Aws::InstanceProfileCredentials 修复了这个

  Searchkick.aws_credentials = {
    credentials: Aws::InstanceProfileCredentials.new,
    region: 'us-west-2',
  }