SQS & SNS
SQS & SNS
Section titled “SQS & SNS”SQS (Simple Queue Service)
Section titled “SQS (Simple Queue Service)”Queue: Type: AWS::SQS::Queue Properties: QueueName: MyQueue VisibilityTimeoutSeconds: 30 MessageRetentionPeriod: 345600 ReceiveMessageWaitTimeSeconds: 20 DeadLetterQueue: TargetArn: !GetAtt DeadLetterQueue.Arn MaxReceiveCount: 3
DeadLetterQueue: Type: AWS::SQS::Queue Properties: QueueName: MyQueueDLQ MessageRetentionPeriod: 1209600SNS (Simple Notification Service)
Section titled “SNS (Simple Notification Service)”Topic: Type: AWS::SNS::Topic Properties: TopicName: MyTopic DisplayName: My Topic
Subscription: Type: AWS::SNS::Subscription Properties: TopicArn: !Ref Topic Protocol: email Endpoint: admin@example.com実践例: イベント駆動アーキテクチャ
Section titled “実践例: イベント駆動アーキテクチャ”# S3イベント → SNS → SQS → LambdaS3Bucket: Type: AWS::S3::Bucket Properties: NotificationConfiguration: TopicConfigurations: - Topic: !Ref SNSTopic Event: s3:ObjectCreated:*
SNSTopic: Type: AWS::SNS::Topic
SQSQueue: Type: AWS::SQS::Queue
SNSSubscription: Type: AWS::SNS::Subscription Properties: TopicArn: !Ref SNSTopic Protocol: sqs Endpoint: !GetAtt SQSQueue.Arn
LambdaFunction: Type: AWS::Lambda::Function Properties: Events: SQS: Type: SQS Properties: Queue: !GetAtt SQSQueue.Arn BatchSize: 10