AWS kinesis将记录丢失无效的安全令牌

时间:2018-04-08 03:35:22

标签: node.js amazon-web-services amazon-kinesis

我有一个nodejs aws客户端,它将记录放到kinesis流中。我很确定我使用的凭据是有效的。但是我收到了这个错误:

error:   Error is  UnrecognizedClientException: The security token included in the request is invalid
    at Request.extractError (/app/node_modules/aws-sdk/lib/protocol/json.js:43:27)
    at Request.callListeners (/app/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/app/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/app/node_modules/aws-sdk/lib/request.js:671:14)

使用aws-cli也会返回类似的错误:

An error occurred (InvalidSignatureException) when calling the PutRecord operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

aws configure list显示正在使用的正确凭据。

除了提供访问密钥,秘密访问密钥和我应该提供的区域之外还有什么东西吗?

1 个答案:

答案 0 :(得分:0)

问题是AWS没有读取提供的凭据(即使脚本可以打印出凭据!)。我正在使用docker来运行这个脚本。改变了kinesis对象的形成方式并且它起作用了:

new AWS.Kinesis({
    accessKeyId: <AWS_ACCESS_KEY_ID>,
    secretAccessKey: <AWS_SECRET_ACCESS_KEY>,
    region: <AWS_REGION>,
  });