AWS CloudFormation配置S3事件到SQS。
创始人
2024-11-14 19:00:46
0

您可以使用AWS CloudFormation配置S3事件到SQS的方法如下所示:

  1. 创建一个S3存储桶(Bucket)和SQS队列(Queue)。
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-bucket

  MyQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: my-queue
  1. 创建一个SQS队列策略(Policy),允许S3存储桶向SQS队列发送消息。
Resources:
  MyQueuePolicy:
    Type: AWS::SQS::QueuePolicy
    Properties:
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal: "*"
            Action: "sqs:SendMessage"
            Resource:
              - !GetAtt MyQueue.Arn
            Condition:
              ArnLike:
                aws:SourceArn: !GetAtt MyBucket.Arn
      Queues:
        - !Ref MyQueue
  1. 创建一个S3事件通知(Notification)配置,将S3事件与SQS队列关联。
Resources:
  MyBucketNotification:
    Type: AWS::S3::BucketNotification
    Properties:
      Bucket: !Ref MyBucket
      NotificationConfiguration:
        QueueConfigurations:
          - Event: s3:ObjectCreated:*
            Queue: !GetAtt MyQueue.Arn

完整的CloudFormation模板示例:

Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-bucket

  MyQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: my-queue

  MyQueuePolicy:
    Type: AWS::SQS::QueuePolicy
    Properties:
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal: "*"
            Action: "sqs:SendMessage"
            Resource:
              - !GetAtt MyQueue.Arn
            Condition:
              ArnLike:
                aws:SourceArn: !GetAtt MyBucket.Arn
      Queues:
        - !Ref MyQueue

  MyBucketNotification:
    Type: AWS::S3::BucketNotification
    Properties:
      Bucket: !Ref MyBucket
      NotificationConfiguration:
        QueueConfigurations:
          - Event: s3:ObjectCreated:*
            Queue: !GetAtt MyQueue.Arn

这样,当S3存储桶中有新的对象创建时,该事件将被发送到SQS队列中。

相关内容

热门资讯

透视能赢(德州微扑克专用)外挂... 透视能赢(德州微扑克专用)外挂透明挂辅助器安装(辅助挂)透视辅助(2025已更新)(哔哩哔哩);亲,...
发现一款(哈糖大菠萝平台)外挂... 发现一款(哈糖大菠萝平台)外挂透明挂辅助软件(透视)原来是真的有挂(可靠教程)(哔哩哔哩)是一款可以...
透视存在(wpk测试)外挂透明... 透视存在(wpk测试)外挂透明挂辅助神器(辅助挂)辅助透视(2020已更新)(哔哩哔哩);亲们利用一...
透视好友房(WPK开挂)外挂透... 透视好友房(WPK开挂)外挂透明挂辅助挂(辅助挂)原来真的有挂(切实教程)(哔哩哔哩),亲,有的,a...
专业讨论(aapoker手游版... 专业讨论(aapoker手游版)外挂透明挂辅助挂(透视)软件透明挂(2022已更新)(哔哩哔哩);值...
透视游戏(德扑之星机制)外挂透... 透视游戏(德扑之星机制)外挂透明挂辅助APP(透视)原来真的有挂(必胜教程)(哔哩哔哩);wpk透视...
分享实测(wePoke)外挂透... 分享实测(wePoke)外挂透明挂辅助工具(透视)软件透明挂(2021已更新)(哔哩哔哩)1、玩家可...
玩家必看科普(德州透视)外挂透... 玩家必看科普(德州透视)外挂透明挂辅助器安装(透视)透视辅助(确实有挂)-哔哩哔哩;wpk透视辅助官...
交流学习经验(鱼扑克app a... 交流学习经验(鱼扑克app ai)外挂透明挂辅助脚本(透视)其实是真的有挂(安装教程)(哔哩哔哩);...
技术分享(wepoke ai)... 技术分享(wepoke ai)外挂透明挂辅助器(透视)软件透明挂(2023已更新)(哔哩哔哩)关于w...