components
components copied to clipboard
Build SNS Component
The aws-sns
component allows users to provision SNS topics, and subscribe services to it (ie. lambda). Having a standalone SNS component allows maximum flexibility by subscribing multiple lambdas to the same topic, or multiple topics to the same lambda. It also allows for all the configurations available for the topic and each of its subscriptions.
I think this approach is the sweet spot between the V1 framework simplicity and CloudFormation flexibility.
Here’s how a simple configuration would look like:
component: aws-sns
name: my-topic
inputs:
description: foo bar
subscriptions:
- aws:arn:lambda
- [email protected]
- +1234567890
You can also provide more configuration for each subscription by converting it into an object:
component: aws-sns
name: my-topic
inputs:
description: foo bar
subscriptions:
- endpoint: aws:arn:lambda
rawMessageDelivery: true
deadLetterQueueArn: aws:arn:sqs
filterPolicy: ...
Integrating the aws-sns
component with the aws-lambda
component is straightforward thanks to our outputs feature, which automatically handles dependencies:
component: aws-sns
name: my-topic
inputs:
description: foo bar
subscriptions:
- ${output:my-lambda-component.arn}
Once we have this component, we could create a couple of templates that demonstrate how components could easily handle event driven architectures.