99x/serverless-dynamodb-local

Error getting DynamoDb local latest tar.gz location undefined: 403

maher-rddi opened this issue ยท 30 comments

Hi, I am getting Error: "Error getting DynamoDb local latest tar.gz location: 403" after doing installing serverless-dynamodb-local.

Here is the full description of the error message:

Started downloading dynamodb-local from http://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz into ***/.dynamodb. Process may take few minutes.

โœ– Uncaught exception
Environment: darwin, node 16.17.0, framework 3.26.0 (local) 3.25.1v (global), plugin 6.2.2, SDK 4.3.2
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues

Error:
Error: Error getting DynamoDb local latest tar.gz location undefined: 403
at ClientRequest.
at Object.onceWrapper (node:events:628:26)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:674:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
at Socket.socketOnData (node:_http_client:521:22)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

It seems that the bucket doesn't authorize my request!

I'm getting the same error, apparently AWS changed the domain to https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz

Edit:
The fix was done in dynamodb-localhost project but not published yet

@matAlmeida Thanks, we will wait for the new release then.

In the meantime, manually editing the download_url in node_modules/dynamodb-localhost/dynamodb/config.json to https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz and the import of http to https in node_modules/dynamodb-localhost/dynamodb/installer.js should do the trick!

@benjiJanssens it worked !! thanks a lot !

cnuss commented

@AshanFernando hey there! now that 99x/dynamodb-localhost#78 is merged, could we get a release to NPM which includes the fix?

@cnuss you're in the wrong repo ๐Ÿ˜„ as soon as dynamodb-localhost gets a new release on npm, we can integrate the changes into serverless-dynamodb-local

cnuss commented

you're in the wrong repo

it appears 99x/serverless-dynamodb-local and 99x/dynamodb-localhost are maintained and released by the same individual(s) so I pinged here since this is the final(ish) destination ๐Ÿ˜„

In the meantime, manually editing the download_url in node_modules/dynamodb-localhost/dynamodb/config.json to https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz and the import of http to https in node_modules/dynamodb-localhost/dynamodb/installer.js should do the trick!

They should really make this configurable.

any update on this issue? it's blocking our CI.

cidit commented

any update on this issue? it's blocking our CI.

youre not alone :')

Sad nothing happens :(

In the meantime, manually editing the download_url in node_modules/dynamodb-localhost/dynamodb/config.json to https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz and the import of http to https in node_modules/dynamodb-localhost/dynamodb/installer.js should do the trick!

It worked for me! Thanks!

cnuss commented

I've found a less-hacky way of getting the URL to update, and considering you're using NPM 8.3.0+ (also worked with yarn 1.22)

NOTE: I needed to clear my node_modules / build cache for this to work:

package.json:

  "devDependencies": {
      ...
      "serverless-dynamodb-local": "...",
      ...
  },
  "overrides": {
    "serverless-dynamodb-local": {
      "dynamodb-localhost": "https://github.com/99x/dynamodb-localhost#db30898f8c40932c7177be7b2f1a81360d12876d"
    }
  }

Ref: 99x/dynamodb-localhost#78
Ref: https://stackoverflow.com/questions/15806152/how-do-i-override-nested-npm-dependency-versions

I had the same issue when trying to run a project. What helped me was changing two files from the node_modules/dynamodb-localhost folder.

In node_modules\dynamodb-localhost\dynamodb\installer.js change http to https:

2023-03-30_17-47

node_modules\dynamodb-localhost\dynamodb\config.json change http to https
image
Maybe this will solve your problem

Any ETA on when this is going to get published?

To whom it may concern:

I faced this issue last week and CircleCI was really not liking it. I ended up adding the following in the scripts section of the packages.json file of the repo I was working with:

  "scripts": {
    "postinstall": "sed -i 's|http://s3-us-west-2|https://s3-us-west-2|g' ./node_modules/dynamodb-localhost/dynamodb/config.json && sed -i 's|require(\"http\")|require(\"https\")|g' ./node_modules/dynamodb-localhost/dynamodb/installer.js",
...
  },

Is it a bit hacky? yes, but I can get over it for now. I'm using sed to modify 2 files.

@jespinal you could use patch-package for that

Edit: adding the link

cnuss commented

I've found a less-hacky way of getting the URL to update, and considering you're using NPM 8.3.0+ (also worked with yarn 1.22)

NOTE: I needed to clear my node_modules / build cache for this to work:

package.json:

  "devDependencies": {
      ...
      "serverless-dynamodb-local": "...",
      ...
  },
  "overrides": {
    "serverless-dynamodb-local": {
      "dynamodb-localhost": "https://github.com/99x/dynamodb-localhost#db30898f8c40932c7177be7b2f1a81360d12876d"
    }
  }

Ref: 99x/dynamodb-localhost#78 Ref: https://stackoverflow.com/questions/15806152/how-do-i-override-nested-npm-dependency-versions

I missed a line in my original comment, it also needs to be set in devDependencies for full integration

  "devDependencies": {
      ...
      "dynamodb-localhost": "https://github.com/99x/dynamodb-localhost#db30898f8c40932c7177be7b2f1a81360d12876d"
      ...
      "serverless-dynamodb-local": "...",
      ...
  },
  "overrides": {
    "serverless-dynamodb-local": {
      "dynamodb-localhost": "https://github.com/99x/dynamodb-localhost#db30898f8c40932c7177be7b2f1a81360d12876d"
    }
  }

Also found some issues with ourdering so make sure dynamodb-localhost is before serverless-dynamodb-local in devDependencies.

I have a doubt, why using pnpm the folder dynamodb-localhost is not created? I can't do the trick to change download_url with pnpm.

I fixed it by simply copying over the .dynamodb folder into the root from another project where I had already run sls dynamodb install before

I have a doubt, why using pnpm the folder dynamodb-localhost is not created? I can't do the trick to change download_url with pnpm.

Doesn't work for me either

Do we have fix this as of now ?

man, this long and no fix? this is annoying

man, this long and no fix? this is annoying

Last publish of the library was 2 years. Should we consider it as dead ?

@ehtesham1996 Seems like it. I guess a fork would be a viable option

In the meantime, manually editing the download_url in node_modules/dynamodb-localhost/dynamodb/config.json to https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz and the import of http to https in node_modules/dynamodb-localhost/dynamodb/installer.js should do the trick!

thank you so much:
I fix it

This issue appears to have been fixed in the latest release without need for any manual editing or switching the config json values

juheba commented

This issue appears to have been fixed in the latest release without need for any manual editing or switching the config json values
On wich dependency is this fixe released?

The newest version via npm is serverless-dynamodb-local 0.2.40 and uses dynamodb-localhost 0.0.9 still with the old url.

As matAlmeida commented on Mar 8: PR 99x/dynamodb-localhost#78 merged but is not released yet.

In the comments are some suggestions provided on how to fix the issue:

  • benjidotsh commented on Mar 9 --> manually modify two files in node_modules/dynamodb-localhost and replace http to https
  • cnuss commented on Apr 2 --> add dynamodb-localhost from github containing the fix to dev dependencies
  • jespinal commented on Mar 31 --> add a postinstall script to package.json with sed commands to modify two files in node_modules/dynamodb-localhost and replace http to https

I used the command from jespinal:

sed -i 's|http://s3-us-west-2|https://s3-us-west-2|g' ./node_modules/dynamodb-localhost/dynamodb/config.json && sed -i 's|require(\"http\")|require(\"https\")|g' ./node_modules/dynamodb-localhost/dynamodb/installer.js

FYI: This package (serverless-dynamodb-local) doesn't appear to be maintained, with no new releases to NPM in over 2 years. Despite our pleas, I don't think this is getting deployed anytime soon. Over time, I think solutions that require creative uses of patch-package or sed will become fragile, and are a pain to maintain on each repo.

Solution: You can use serverless-dynamodb, a maintained fork, instead. (Disclaimer: I am a contributor to this fork). It is a drop-in replacement for this package, and is updated to fix this bug. This is a drop-in replacement for serverless-dynamodb-local, so to upgrade simply:

  1. Uninstall serverless-dynamodb-local, e.g. npm uninstall serverless-dynamodb-local
  2. Install serverless-dynamodb, e.g. npm install serverless-dynamodb
  3. Update references in your code, including your serverless config, from serverless-dynamodb-local to serverless-dynamodb (quite possible that you won't have any, as you just refer to it from your serverless config)
  4. (optional) Update your serverless config custom dynamodb key to serverless-dynamodb

Of course, it's all still open-source and MIT licensed. Ownership of this new package sits with a registered charity, that is committed to maintaining the package into the future and is open to contributions from the community.

There's an explanation as to the intentions behind this fork, and how it compares to other forks in the README.

In any case would be open to feedback on the fork - can drop create an issue in that repository or email me (address on profile).

Thank youu!