Describe the story
Create a SNS client utility which serves as a wrapper around the AWS SDK SNSClient. This should simplify the creation of the AWS SDK SNS client and it should store the created instance as a singleton for reuse across Lambda function invocations.
The wrapper should provide a publishToTopic helper function which publishes a message and attributes, i.e. message attributes, to a SNS topic by the Topic ARN.
The wrapper should provide a getter which returns the singleton instance of the SNSClient.
Acceptance criteria
GIVEN the app initializes an instance of the SNS client
WHEN no parameters are supplied to the initializer
THEN an instance of the client is created using the default configuration for the SNSClient
WHEN the SNSClientConfig is provided to the initializer
THEN the SNSClient instance is constructed using the supplied configuration
WHEN the SNSClient instances are constructed
THEN they are cached as singleton instances
GIVEN the publishToTopic function is invoked
WHEN the singleton instance does not exist
THEN a SNSClient instance is constructed with default configuration
AND the instance is cached as the singleton
AND the instance is used by the publishToTopic function
WHEN the singleton instance already exists
THEN the instance is used by the publishToTopic function
Additional context
Add any other context about the story here.
Describe the story
Create a SNS client utility which serves as a wrapper around the AWS SDK
SNSClient. This should simplify the creation of the AWS SDK SNS client and it should store the created instance as a singleton for reuse across Lambda function invocations.The wrapper should provide a
publishToTopichelper function which publishes amessageandattributes, i.e. message attributes, to a SNS topic by the Topic ARN.The wrapper should provide a getter which returns the singleton instance of the
SNSClient.Acceptance criteria
GIVEN the app initializes an instance of the SNS client
WHEN no parameters are supplied to the initializer
THEN an instance of the client is created using the default configuration for the SNSClient
WHEN the
SNSClientConfigis provided to the initializerTHEN the
SNSClientinstance is constructed using the supplied configurationWHEN the
SNSClientinstances are constructedTHEN they are cached as singleton instances
GIVEN the
publishToTopicfunction is invokedWHEN the singleton instance does not exist
THEN a
SNSClientinstance is constructed with default configurationAND the instance is cached as the singleton
AND the instance is used by the
publishToTopicfunctionWHEN the singleton instance already exists
THEN the instance is used by the
publishToTopicfunctionAdditional context
Add any other context about the story here.