S3 - Amazon Serverless Application Model
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

S3

描述 S3 事件源类型的对象。

语法

要在您的 Amazon Serverless Application Model (Amazon SAM) 模板中声明此实体,请使用以下语法。

YAML

Bucket: String Events: String | List Filter: NotificationFilter

属性

Bucket

S3 桶名称。此存储桶必须存在于同一模板中。

类型:字符串

必需:是

Amazon CloudFormation 兼容性:此属性类似于 AWS::S3::Bucket 资源的 BucketName 属性。在 SAM 中此为必填字段。此字段仅接受对此模板中创建的 S3 存储桶的引用

Events

调用 Lambda 函数的 Amazon S3 桶事件。有关有效值的列表,请参阅 Amazon S3 支持的事件类型

类型:字符串 | 列表

必需:是

Amazon CloudFormation 兼容性:此属性直接传递给 AWS::S3::Bucket LambdaConfiguration 数据类型的 Event 属性。

Filter

确定哪些 Amazon S3 对象调用 Lambda 函数的筛选规则。有关 Amazon S3 键名筛选的信息,请参阅《Amazon Simple Storage Service 用户指南》中的配置 Amazon S3 事件通知

类型:NotificationFilter

必需:否

Amazon CloudFormation 兼容性:此属性直接传递给 AWS::S3::Bucket LambdaConfiguration 数据类型的 Filter 属性。

示例

S3 事件

S3 事件示例。

YAML

Events: S3Event: Type: S3 Properties: Bucket: Ref: ImagesBucket # This must be the name of an S3 bucket declared in the same template file Events: s3:ObjectCreated:* Filter: S3Key: Rules: - Name: prefix # or "suffix" Value: value # The value to search for in the S3 object key names