Cannot find module aws-sdk client-sns

0 votes

I am getting this error when calling my lambda.

"errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module '@aws-sdk/client-sns'\nRequire stack:\n- /var/task/handler.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js", "trace": [ "Runtime.ImportModuleError: Error: Cannot find module '@aws-sdk/client-sns'",

import * as AWS from '@aws-sdk/client-sns';
import { JamaSnsMessage } from './models/jama';
import { region, snsTopicArn } from './utils/constants';
import { log } from './utils/logger';

const client = new AWS.SNS({ region });

/**
 * Publishes given SNS formatted Jama items to SNS topic
 *
 * @param {JamaSnsMessage[]} items
 */
export const publishItems = async (items: JamaSnsMessage[]): Promise<void> => {
  if (!items || items.length <= 0) {
    return;
  }

  for (const item of items) {
    const params = {
      /* eslint-disable */
      MessageStructure: 'json',
      Message: JSON.stringify(item),
      TopicArn: snsTopicArn,
      /* eslint-enable */
    };
    log.info(`Sending jama item: ${JSON.stringify(item)} to sns`);
    await send(params);
  }
};

export const send = async (params: AWS.PublishInput): Promise<void> => {
  try {
    const data = await client.send(new AWS.PublishCommand(params));
    log.info(`Item: ${JSON.stringify(params)} was published with id: ${data.MessageId}`);
  } catch (error) {
    log.error(`Error while publishing message ${JSON.stringify(params)}. Cause: ${error}`);
  }
};

Feb 16 in AWS by Ashwini
• 4,070 points
147 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer

Error creating DB Instance: InvalidParameterCombination: Cannot find version 5.6.10a for aurora-mysql

I guess engine name 'aurora-mysql' refers to ...READ MORE

answered Sep 24, 2018 in AWS by Priyaj
• 58,100 points
5,884 views
+1 vote
1 answer

[WinError 2] The system cannot find the file specified

Hi@akhtar, You may get this error, if you ...READ MORE

answered Jun 1, 2020 in AWS by MD
• 95,460 points
2,803 views
+3 votes
3 answers

Terraform AWS Cognito App Client

This feature is not currently supported by ...READ MORE

answered Aug 28, 2018 in AWS by eatcodesleeprepeat
• 4,710 points
2,530 views
+1 vote
2 answers

How do I get my AWS Glue client in JAVA?

Hey, you've been using a correct code ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,660 points
3,706 views
0 votes
1 answer

AmazonServiceException: Unable to find credentials

It should be a problem with AWS ...READ MORE

answered Feb 12, 2019 in AWS by Archana
• 5,640 points
1,688 views
0 votes
0 answers

How to get response from S3 getObject in Node.js?

I am attempting to get data back ...READ MORE

Apr 23, 2022 in Others by Kichu
• 19,050 points
1,149 views
0 votes
1 answer

Invalid Bucket name when creating s3 bucket with AWS SDK

AWS provides naming standards when naming an ...READ MORE

answered Aug 30, 2018 in AWS by Priyaj
• 58,100 points
3,469 views
0 votes
1 answer

Task Canceled Exception while invoking AWS Lambda

I'm guessing either the TaskCanceledException instance is ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,100 points
1,791 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP