0

I have a NodeJS server that used the AWS SDK v2. I started seeing these messages:

NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy

I ran the suggested command npx aws-sdk-js-codemod --dry --print -t v2-to-v3 routes/users.js, some lines get changed, but the code hangs due to a .promise() that the codemod missed.

I read the documentation and tried this code, copied straight from the documentation:

const {sns, sns_add_permission_command} = require("@aws-sdk/client-sns");
const sns_client = new sns({
  region: "eu-west-1",
  apiVersion: '2010-03-31'
});

And I get this error:

const sns_client = new sns({
                   ^

TypeError: sns is not a constructor

What am I doing wrong?

2
  • 1
    No, that's not what the docs have. It's SNSClient.
    – stdunbar
    Commented Jun 3, 2023 at 18:05
  • @stdunbar Indeed, that fixes the issue. Why does renaming a variable or const cause that error?
    – emonigma
    Commented Jun 4, 2023 at 20:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.