emmkong / serverless-plugin-offline-dynamodb-stream

Serverless Plugin for emulating dynamodb stream triggering lambda functions offline
MIT License
27 stars 19 forks source link

ResourceNotFoundException: Requested resource not found #14

Open thecherrytree opened 4 years ago

thecherrytree commented 4 years ago

Hi, thanks for building this. I'm hoping I can get it working.

My local setup is trying to call lambda from dynamodb stream. I'm using this in conjunction with serverless-offline and localstack.

Resource Not Found Exception ---------------------------

  ResourceNotFoundException: Requested resource not found: Stream: arn:aws:dynamodb:us-east-1:000000000000:table/fte-dev/stream/2019-10-16T14:24:00.499 not found
      at Request.extractError (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/protocol/json.js:48:27)
      at Request.callListeners (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
      at Request.emit (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
      at Request.emit (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:683:14)
      at Request.transition (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:22:10)
      at AcceptorStateMachine.runTo (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/state_machine.js:14:12)
      at ~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/state_machine.js:26:10
      at Request.<anonymous> (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:38:9)
      at Request.<anonymous> (~//node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:685:12)
      at Request.callListeners (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
      at Request.emit (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
      at Request.emit (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:683:14)
      at Request.transition (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:22:10)
      at AcceptorStateMachine.runTo (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/state_machine.js:14:12)
      at ~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/state_machine.js:26:10
      at Request.<anonymous> (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:38:9)
      at Request.<anonymous> (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/request.js:685:12)
      at Request.callListeners (~i/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
      at callNextListener (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
      at IncomingMessage.onEnd (~/node_modules/serverless-plugin-offline-dynamodb-stream/node_modules/aws-sdk/lib/event_listeners.js:269:13)
      at IncomingMessage.emit (events.js:193:15)
      at IncomingMessage.EventEmitter.emit (domain.js:441:20)
      at endReadableNT (_stream_readable.js:1129:12)
      at process.internalTickCallback (internal/process/next_tick.js:72:19)

However when I call list-streams, the stream is there: awslocal dynamodbstreams list-streams

{
    "Streams": [
        {
            "StreamArn": "arn:aws:dynamodb:us-east-1:000000000000:table/fte-dev/stream/2019-10-16T14:24:00.499",
            "TableName": "fte-dev",
            "StreamLabel": "2019-10-16T14:24:00.499"
        },
        {
            "StreamArn": "arn:aws:dynamodb:us-east-1:000000000000:table/fte2-dev/stream/2019-10-16T14:24:09.862",
            "TableName": "fte2-dev",
            "StreamLabel": "2019-10-16T14:24:09.862"
        }
    ],
    "LastEvaluatedStreamArn": "TODO"
}

And when I describe-table:

awslocal dynamodb describe-table --table-name fte-dev

{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "sd_nur",
                "AttributeType": "S"
            },
            {
                "AttributeName": "arch_rmr",
                "AttributeType": "S"
            }
        ],
        "TableName": "fte-dev",
        "KeySchema": [
            {
                "AttributeName": "sd_nur",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "arch_rmr",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": 1571235840.499,
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": 0.0,
            "LastDecreaseDateTime": 0.0,
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 1,
            "WriteCapacityUnits": 1
        },
        "TableSizeBytes": 23677,
        "ItemCount": 4,
        "TableArn": "arn:aws:dynamodb:us-east-1:000000000000:table/fte-dev",
        "BillingModeSummary": {
            "BillingMode": "PROVISIONED",
            "LastUpdateToPayPerRequestDateTime": 0.0
        },
        "StreamSpecification": {
            "StreamEnabled": true,
            "StreamViewType": "NEW_AND_OLD_IMAGES"
        },
        "LatestStreamLabel": "2019-10-16T14:24:00.499",
        "LatestStreamArn": "arn:aws:dynamodb:us-east-1:000000000000:table/fte-dev/stream/2019-10-16T14:24:00.499"
    }
}

Here is my setup:

Not sure what I'm doing wrong here...

thecherrytree commented 4 years ago

This might be a localstack issue? I've opened an issue with them as well: https://github.com/localstack/localstack/issues/1655

cyberwombat commented 4 years ago

I had a similar issue. I use DynamodDB local which requires mock credentials - I set my .env to pass MOCK_ACCESS_KEY_ID and MOCK_SECRET_ACCESS_KEY respectively. After modifying calls to all dynamoDB and dynamoDBStreams such as:

new AWS.DynamoDBStreams({ region, accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey:  process.env.AWS_SECRET_ACCESS_KEY });

Then it works fine. Perhaps these creds could be added to config?

cyberwombat commented 4 years ago

Ahhh - the pleasure of having the same issue, searching for it and finding my own answer from last year as a solution. I should tip myself beer money.