2015-03-19 71 views
3

我試圖建立我的S3通知我SQS隊列的「PUT」對象的創建活動。發佈S3桶通知到SQS

我能夠通過實現這個使用CLI:

aws --profile QA s3api put-bucket-notification --bucket <BUCKET_NAME> --notification-configuration '{ "QueueConfiguration": { "Id": "<EVENT ID>", "Event": "s3:ObjectCreated:Put", "Queue": "<QUEUE ARN>" } }' 

也能做到使用Java一樣:

NotificationConfiguration notificationConfiguration = new QueueConfiguration(queueArn, EnumSet.of(S3Event.ObjectCreatedByPut)); 
BucketNotificationConfiguration bucketNotificationConfiguration = new BucketNotificationConfiguration("DropShipInboundQueueDelivery", notificationConfiguration); 
client.setBucketNotificationConfiguration(bucketName, bucketNotificationConfiguration) 

然而,當我試圖類似的東西使用CloudFormation模板,我不能找到任何方式來觸發通知SQS。我看到的唯一可行的方法是記錄SNS通知。

我所提到的雲的形成文檔:

  • 我看着AWS::S3::Bucket文檔看外語法。我看到NotificationConfiguration,我需要設置
  • 然而Notification Configuration只能包含TopicConfigurations同是老構造在JDK的列表之前QueueConfiguration

我試圖做這樣的事情得到了支持:

"NotificationConfiguration" :{ 
    "QueueConfiguration": { 
     "Id": "DropshipInboundEventNotification", 
     "Event": "s3:ObjectCreated:Put", 
     "Queue": "arn:aws:sqs:*:*:Dropship-Inbound-qa" 
    } 
}, 

但這種預期拋出一個錯誤:從亞馬遜「遇到不支持的屬性QueueConfiguration」。

搜索這API documentation

我想知道是否有人已經能夠做到這一點使用CloudFormation模板,因爲這就是我如何保持所有其他AWS資源,不希望爲這個特殊的做特別的特徵。

任何幫助表示讚賞。

+0

我還沒有嘗試過這個功能我自己,但我發現CloudFormation一般要滯後幾個月的訂單上的API後面。如果有一個變化的一段時間回來,如何這工作的,很可能只是還沒有遷移到CF ......了嗎? – DanielM 2015-09-09 16:13:22

回答

0

在CloudForms模板中不需要「Id」(您可以從QueueConfiguration Doc中查到)和第二個錯誤,那就是「QueueConfiguration」,它是「QueueConfigurations」。正因爲如此你,說:「遇到不支持的屬性QueueConfiguration」

它必須是這樣的一個錯誤。

"S3Bucket":{ 
    "Type" : "AWS::S3::Bucket", 
    "Properties" : { 
     "AccessControl" : String, 
     "BucketName" : String, 
     "CorsConfiguration" : CORS Configuration, 
     "LifecycleConfiguration" : Lifecycle Configuration, 
     "LoggingConfiguration" : Logging Configuration, 
     "NotificationConfiguration" : 

{ "QueueConfigurations" : [ { 
    "Event" : "s3:ObjectCreated:Put", 
    "Queue" : "arn:YOURQUEUEARN" 
} ] }, 

     "Tags" : [ Resource Tag, ... ], 
     "VersioningConfiguration" : Versioning Configuration, 
     "WebsiteConfiguration" : Website Configuration Type 
    } 
}  

當你正在閱讀cloudformation模板文件,你必須小心「要求:」部分。如果不需要它,你不需要填充它,只是從你的模板中刪除了這一行,如果你不使用它(像S3標籤)。

關於它的其他文檔:

S3BucketDocs

NotificationConfigurationDocs

+0

克里姆,感謝您的更新。我注意到這是幾天前添加的。任何工作在相同問題上的人都應該能夠利用這個解決方案。 – 2015-10-21 22:13:26