

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# CloudWatchEvent
<a name="sam-property-function-cloudwatchevent"></a>

Objek yang menggambarkan tipe sumber peristiwa `CloudWatchEvent`.

AWS Serverless Application Model (AWS SAM) menghasilkan [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html)sumber daya saat jenis acara ini disetel.

**Catatan Penting**: [EventBridgeRule](sam-property-function-eventbridgerule.md) adalah jenis sumber acara yang disukai untuk digunakan, bukan`CloudWatchEvent`. `EventBridgeRule`dan `CloudWatchEvent` menggunakan layanan, API, dan CloudFormation sumber daya dasar yang sama. Namun, AWS SAM akan menambahkan dukungan untuk fitur baru hanya untuk`EventBridgeRule`.

## Sintaksis
<a name="sam-property-function-cloudwatchevent-syntax"></a>

Untuk mendeklarasikan entitas ini dalam template AWS Serverless Application Model (AWS SAM) Anda, gunakan sintaks berikut.

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

```
  [Enabled](#sam-function-cloudwatchevent-enabled): Boolean
  [EventBusName](#sam-function-cloudwatchevent-eventbusname): String
  [Input](#sam-function-cloudwatchevent-input): String
  [InputPath](#sam-function-cloudwatchevent-inputpath): String
  [Pattern](#sam-function-cloudwatchevent-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  [State](#sam-function-cloudwatchevent-state): String
```

## Sifat-sifat
<a name="sam-property-function-cloudwatchevent-properties"></a>

 `Enabled`   <a name="sam-function-cloudwatchevent-enabled"></a>
Menunjukkan apakah aturan diaktifkan.  
Untuk menonaktifkan aturan, tetapkan properti ini ke `false`.  
Tentukan salah satu `Enabled` atau `State` properti, tetapi tidak keduanya.
*Tipe*: Boolean  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini mirip dengan `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` properti `AWS::Events::Rule` sumber daya. Jika properti ini diatur untuk `true` kemudian AWS SAM lolos`ENABLED`, jika tidak maka akan lewat`DISABLED`.

 `EventBusName`   <a name="sam-function-cloudwatchevent-eventbusname"></a>
Bus peristiwa yang akan dihubungkan dengan aturan ini. Jika Anda menghilangkan properti ini, AWS SAM gunakan bus acara default.  
*Tipe*: String  
*Wajib*: Tidak  
*Default*: Bus peristiwa default  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` properti `AWS::Events::Rule` sumber daya.

 `Input`   <a name="sam-function-cloudwatchevent-input"></a>
Teks JSON yang valid yang dilewatkan ke target. Jika Anda menggunakan properti ini, tidak ada dari teks peristiwa itu sendiri yang diteruskan ke target.  
*Tipe*: String  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` properti `AWS::Events::Rule Target` sumber daya.

 `InputPath`   <a name="sam-function-cloudwatchevent-inputpath"></a>
Bila Anda tidak ingin meneruskan seluruh peristiwa yang sesuai ke target, gunakan properti `InputPath` untuk menggambarkan bagian mana dari peristiwa yang akan diteruskan.  
*Tipe*: String  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` properti `AWS::Events::Rule Target` sumber daya.

 `Pattern`   <a name="sam-function-cloudwatchevent-pattern"></a>
Menjelaskan peristiwa yang dirutekan ke target yang ditentukan. Untuk informasi selengkapnya, lihat [Peristiwa dan Pola Peristiwa EventBridge di](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html) *Panduan EventBridge Pengguna Amazon*.  
*Jenis*: [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*Wajib*: Ya  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` properti `AWS::Events::Rule` sumber daya.

 `State`   <a name="sam-function-cloudwatchevent-state"></a>
Keadaan aturan.  
*Nilai yang diterima:* `DISABLED | ENABLED`  
Tentukan salah satu `Enabled` atau `State` properti, tetapi tidak keduanya.
*Tipe*: String  
*Wajib*: Tidak  
*CloudFormation kompatibilitas*: Properti ini diteruskan langsung ke `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` properti `AWS::Events::Rule` sumber daya.

## Contoh
<a name="sam-property-function-cloudwatchevent--examples"></a>

### CloudWatchEvent
<a name="sam-property-function-cloudwatchevent--examples--cloudwatchevent"></a>

Berikut adalah contoh peristiwa dari tipe sumber peristiwa `CloudWatchEvent`.

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

```
CWEvent:
  Type: CloudWatchEvent
  Properties:
    Enabled: false
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - running
```