123
123

Reputation: 197

SNS SDK for NodeJS won't create FIFO topic

When I create a topic using the sns.createTopic (like the code below) it won't accept the booleans and say 'InvalidParameterType: Expected params.Attributes['FifoTopic'] to be a string', even though the docs say to provide boolean value, and when I provide it with a string of 'true' it still doesn't set the topic type to be FIFO, anyone knows why?

Here's the code:

const TOPIC = {
    Name: 'test.fifo',
    Attributes: {
        FifoTopic: true,
        ContentBasedDeduplication: true
    },
    Tags: [{
        Key: 'test-key',
        Value: 'test-value'
    }]
};
sns.createTopic(TOPIC).promise().then(console.log);

Upvotes: 0

Views: 410

Answers (1)

Siva Sumanth
Siva Sumanth

Reputation: 662

  • Used aws-sdk V2
  • I sent FifoTopic and ContentBasedDeduplication as strings.

The below code works fine for me

const TOPIC = {
    Name: 'test.fifo',
    Attributes: {
        FifoTopic: "true",
        ContentBasedDeduplication: "true"
    },
    Tags: [{
        Key: 'test-key',
        Value: 'test-value'
    }]
};
let sns = new AWS.SNS();
let response3 =await sns.createTopic(TOPIC).promise();
console.log(response3);

Note: Make sure your lambda has correct permissions. enter image description here

  • You will be getting attributes like FifoTopic and ContentBasedDeduplication when performing the getTopicAttributes.

    let respo = await sns.getTopicAttributes({ TopicArn:"arn:aws:sns:us-east-1:XXXXXXX:test.fifo"} ).promise();

please find the screenshot enter image description here

Upvotes: 1

Related Questions