Skip to Content

DVA-C02: How to Use AWS Lambda and Amazon SNS to Notify Partners of Food Orders

Learn how to build a microservices application that uses AWS Lambda and Amazon SNS to process and notify food orders from multiple partners. Find out how to use SNS topics, subscriptions, and filter policies.

Table of Contents

Question

A company receives food orders from multiple partners. The company has a microservices application that uses Amazon API Gateway APIs with AWS Lambda integration. Each partner sends orders by calling a customized API that is exposed through API Gateway. The API call invokes a shared Lambda function to process the orders.

Partners need to be notified after the Lambda function processes the orders. Each partner must receive updates for only the partner’s own orders. The company wants to add new partners in the future with the fewest code changes possible.

Which solution will meet these requirements in the MOST scalable way?

A. Create a different Amazon Simple Notification Service (Amazon SNS) topic for each partner. Configure the Lambda function to publish messages for each partner to the partner’s SNS topic.

B. Create a different Lambda function for each partner. Configure the Lambda function to notify each partner’s service endpoint directly.

C. Create an Amazon Simple Notification Service (Amazon SNS) topic. Configure the Lambda function to publish messages with specific attributes to the SNS topic. Subscribe each partner to the SNS topic. Apply the appropriate filter policy to the topic subscriptions.

D. Create one Amazon Simple Notification Service (Amazon SNS) topic. Subscribe all partners to the SNS topic.

Answer

C. Create an Amazon Simple Notification Service (Amazon SNS) topic. Configure the Lambda function to publish messages with specific attributes to the SNS topic. Subscribe each partner to the SNS topic. Apply the appropriate filter policy to the topic subscriptions.

Explanation

The correct answer is C. Create an Amazon Simple Notification Service (Amazon SNS) topic. Configure the Lambda function to publish messages with specific attributes to the SNS topic. Subscribe each partner to the SNS topic. Apply the appropriate filter policy to the topic subscriptions.

Here is an explanation of why this solution will meet the requirements in the most scalable way:

  • The problem is that the company receives food orders from multiple partners, and needs to notify each partner after a shared Lambda function processes the orders. Each partner must receive updates for only their own orders, and the company wants to add new partners in the future with the fewest code changes possible.
  • To solve this problem, the company needs to use a service that can send messages to multiple subscribers in a decoupled and scalable way. SNS is a fully managed service that provides pub/sub messaging and mobile notifications. It can send messages to various endpoints, such as email, SMS, HTTP, Lambda functions, or other AWS services.
  • The solution that meets the requirements in the most scalable way is to create an SNS topic, and configure the Lambda function to publish messages with specific attributes to the topic. A message attribute is a key-value pair that provides additional information about a message. The Lambda function can use message attributes to identify which partner sent the order, and what is the status of the order processing. For example, the Lambda function can publish a message with attributes such as partner: A and status: success to indicate that partner A’s order was processed successfully.
  • The company can then subscribe each partner to the SNS topic, and apply an appropriate filter policy to the topic subscriptions. A filter policy is a JSON object that defines which messages a subscriber wants to receive based on their attributes. The company can use filter policies to ensure that each partner receives only the messages that are relevant to their orders. For example, partner A can have a filter policy such as {“partner”: [“A”]}, which means that they will receive only the messages that have partner: A as an attribute.
  • This solution will meet the requirements in the most scalable way because it will enable the company to notify each partner about their own orders in a reliable and efficient manner, without coupling them with the Lambda function or each other. It will also allow the company to add new partners in the future with minimal code changes, as they only need to subscribe them to the SNS topic and apply a filter policy.

Therefore, option C is the correct solution that will meet the requirements in the most scalable way. Option A is incorrect because it will require creating and managing multiple SNS topics, which will add more resources and costs to the application. Option B is incorrect because it will require creating and managing multiple Lambda functions, which will add more resources and costs to the application. Option D is incorrect because it will not allow each partner to receive updates for only their own orders, as they will receive all messages from the SNS topic.

The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.

AWS Certified Developer - Associate DVA-C02 Exam Questions and Answers