When can we expect sns cdk to support FIFO? https://docs.aws.amazon.com/cdk/api/latest/docs/aws-sns-readme.html
This is a 馃摃 documentation issue
+1, really waiting for this.
Is it just a documentation issue? Does that mean that I can build SNS FIFO already?
Since FIFO Topic support has been added to Cloudformation already, and aws-sns already contain a Topic construct - you can use the cdk escape hatch approach and add raw property overrides to create an SNS fifo topic.
That way you can have FIFO Topics created from CDK now, without waiting for a cdk release that includes it directly.
I made a small helper method like this (typescript) - note we have a naming convention in our team so FIFO topics and queues end with .fifo - I'm not completely sure if that is actually needed:
public static createFifoTopic(stack: Stack, name: string) {
if (!name.endsWith('.fifo')) name = name + '.fifo';
const topic = new sns.Topic(stack, name, {
topicName: name
});
const cfnTopic = topic.node.defaultChild as CfnTopic
cfnTopic.addPropertyOverride("FifoTopic", true);
cfnTopic.addPropertyOverride("ContentBasedDeduplication", false);
return topic;
}
Which called like this
SnsComponent.createFifoTopic(stack, 'foo')
Will result in an SNS::Topic template like this:
"foofifoCAF914F4": {
"Type": "AWS::SNS::Topic",
"Properties": {
"ContentBasedDeduplication": false,
"TopicName": "foo.fifo",
"FifoTopic": true
},
"Metadata": {
"aws:cdk:path": "fooservice-stack/foo.fifo/Resource"
}
},
See - https://docs.aws.amazon.com/sns/latest/dg/fifo-topic-code-examples.html
and - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw
@frjtrifork thank you, that was very helpful!
It seems there is a bug in CloudFormation, the TopicName with the .fifo ending should be created correctly from CloudFormation, but this does not happen currently. That's why @frjtrifork uses fix name with .fifo ending probably?
Hello, I'm opening a PR now to support content-based deduplication and FIFO topics using the Topic
CDK construct.
Any idea when would it be released after merging PR? This is a super needed feature.
Most helpful comment
Since FIFO Topic support has been added to Cloudformation already, and aws-sns already contain a Topic construct - you can use the cdk escape hatch approach and add raw property overrides to create an SNS fifo topic.
That way you can have FIFO Topics created from CDK now, without waiting for a cdk release that includes it directly.
I made a small helper method like this (typescript) - note we have a naming convention in our team so FIFO topics and queues end with .fifo - I'm not completely sure if that is actually needed:
Which called like this
SnsComponent.createFifoTopic(stack, 'foo')
Will result in an SNS::Topic template like this:
See - https://docs.aws.amazon.com/sns/latest/dg/fifo-topic-code-examples.html
and - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw