Skip to content

Commit 4a27956

Browse files
authored
Update README.md
1 parent 3aa20d8 commit 4a27956

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,139 @@ events:
475475
rate: rate(2 hours)
476476
```
477477

478+
### CloudWatch Event
479+
## Simple event definition
480+
481+
This will enable your Step Functions to be called by an EC2 event rule.
482+
Please check the page of [Event Types for CloudWatch Events](http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html).
483+
484+
```yml
485+
stepFunctions:
486+
stateMachines:
487+
first:
488+
events:
489+
- cloudwatchEvent:
490+
event:
491+
source:
492+
- "aws.ec2"
493+
detail-type:
494+
- "EC2 Instance State-change Notification"
495+
detail:
496+
state:
497+
- pending
498+
definition:
499+
...
500+
```
501+
502+
## Enabling / Disabling
503+
504+
**Note:** `cloudwatchEvent` events are enabled by default.
505+
506+
This will create and attach a disabled `cloudwatchEvent` event for the `myCloudWatch` statemachine.
507+
508+
```yml
509+
stepFunctions:
510+
stateMachines:
511+
cloudwatchEvent:
512+
events:
513+
- cloudwatchEvent:
514+
event:
515+
source:
516+
- "aws.ec2"
517+
detail-type:
518+
- "EC2 Instance State-change Notification"
519+
detail:
520+
state:
521+
- pending
522+
enabled: false
523+
definition:
524+
...
525+
```
526+
527+
## Specify Input or Inputpath
528+
529+
You can specify input values ​​to the Lambda function.
530+
531+
```yml
532+
stepFunctions:
533+
stateMachines:
534+
cloudwatchEvent:
535+
events:
536+
- cloudwatchEvent:
537+
event:
538+
source:
539+
- "aws.ec2"
540+
detail-type:
541+
- "EC2 Instance State-change Notification"
542+
detail:
543+
state:
544+
- pending
545+
input:
546+
key1: value1
547+
key2: value2
548+
stageParams:
549+
stage: dev
550+
- cloudwatchEvent:
551+
event:
552+
source:
553+
- "aws.ec2"
554+
detail-type:
555+
- "EC2 Instance State-change Notification"
556+
detail:
557+
state:
558+
- pending
559+
inputPath: '$.stageVariables'
560+
definition:
561+
...
562+
```
563+
564+
## Specifying a Description
565+
566+
You can also specify a CloudWatch Event description.
567+
568+
```yml
569+
stepFunctions:
570+
stateMachines:
571+
cloudwatchEvent:
572+
events:
573+
- cloudwatchEvent:
574+
description: 'CloudWatch Event triggered on EC2 Instance pending state'
575+
event:
576+
source:
577+
- "aws.ec2"
578+
detail-type:
579+
- "EC2 Instance State-change Notification"
580+
detail:
581+
state:
582+
- pending
583+
definition:
584+
...
585+
```
586+
587+
## Specifying a Name
588+
589+
You can also specify a CloudWatch Event name. Keep in mind that the name must begin with a letter; contain only ASCII letters, digits, and hyphens; and not end with a hyphen or contain two consecutive hyphens. More infomation [here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html).
590+
591+
```yml
592+
stepFunctions:
593+
stateMachines:
594+
cloudwatchEvent:
595+
events:
596+
- cloudwatchEvent:
597+
name: 'my-cloudwatch-event-name'
598+
event:
599+
source:
600+
- "aws.ec2"
601+
detail-type:
602+
- "EC2 Instance State-change Notification"
603+
detail:
604+
state:
605+
- pending
606+
definition:
607+
...
608+
```
609+
610+
478611
## Command
479612
### deploy
480613
Run `sls deploy`, the defined Stepfunctions are deployed.

0 commit comments

Comments
 (0)