最近在备考AWS架构师认证,发现一道有意思的题目。网上都找不到正解。
题目如下:
A company's operations team has an existing Amazon S3 bucket configured to notify an Amazon SQS queue when new objects are created within the bucket. The development team also wants to receive events when new objects are created. The existing operations team workflow must remain intact.
Which solution would satisfy these requirements?
A. Create another SQS queue. Update the S3 events in the bucket to also update the new queue when a new object is created.
B. Create a new SQS queue that only allows Amazon S3 to access the queue. Update Amazon S3 to update this queue when a new object is created.
C. Create an Amazon SNS topic and SQS queue for the bucket updates. Update the bucket to send events to the new topic. Updates both queues to poll Amazon SNS.
D. Create an Amazon SNS topic and SQS queue for the bucket updates. Update the bucket to send events to the new topic. Add subscriptions for both queues in the topic.
正解是D。
其实光看题目A似乎是一个更简单的问题,但是亲身实践了以后,会发现,
如果在S3中创建两条event,包含相同的触发条件,在创建时会报错:
所以两条一样触发条件的event,必须合在一起配置。
一起配置就只能有一个Destination。一个SNS或者一个SQS或者一个Lambda。不能配置两个SQS。如下图:
A与B就肯定不对了。
C的问题在于SNS能主动推送,不需要poll,这是SNS和SQS的主要区别。SQS才需要poll。
所以D才是正解,通过创建一个SNS,作为S3 event通知的Destination。
然后在SNS中配置两个SQS的Subscriptions,一个给operations team,一个给development team。保证了operations team的SQS不被影响。