

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# S3
<a name="sam-property-function-s3"></a>

描述`S3`事件來源類型的物件。

## 語法
<a name="sam-property-function-s3-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-property-function-s3-syntax.yaml"></a>

```
  [Bucket](#sam-function-s3-bucket): String
  [Events](#sam-function-s3-events): String | List
  [Filter](#sam-function-s3-filter): [NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)
```

## Properties
<a name="sam-property-function-s3-properties"></a>

 `Bucket`   <a name="sam-function-s3-bucket"></a>
S3 儲存貯體名稱。此儲存貯體必須存在於相同的範本中。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::S3::Bucket` 資源的 `[BucketName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-name)` 屬性。這是 SAM 中的必要欄位。此欄位僅接受在此範本中建立之 S3 儲存貯體的參考

 `Events`   <a name="sam-function-s3-events"></a>
要叫用 Lambda 函數的 Amazon S3 儲存貯體事件。如需有效值的清單，請參閱 [Amazon S3 支援的事件類型](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types)。  
*類型*：字串 \$1 清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Event](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig-lambdaconfig.html#cfn-s3-bucket-notificationconfig-lambdaconfig-event)` 屬性。

 `Filter`   <a name="sam-function-s3-filter"></a>
篩選規則，決定哪些 Amazon S3 物件叫用 Lambda 函數。如需 Amazon S3 金鑰名稱篩選的相關資訊，請參閱[《Amazon Simple Storage Service 使用者指南》中的設定 Amazon S3 事件通知](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html)。 **  
*類型*：[NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Filter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)` 屬性。

## 範例
<a name="sam-property-function-s3--examples"></a>

### S3-Event
<a name="sam-property-function-s3--examples--s3-event"></a>

S3 事件的範例。

#### YAML
<a name="sam-property-function-s3--examples--s3-event--yaml"></a>

```
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
```