Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer committed Mar 15, 2024
1 parent 57bdf9d commit 6a21c6d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,7 @@ The [CreateSchedule](https://docs.aws.amazon.com/scheduler/latest/APIReference/A
Here is an example of how to create a schedule that puts an event to SQS queue every 5 minutes:

```ts
import * as iam from 'aws-cdk-lib/aws-iam';
import * as key from 'aws-cdk-lib/aws-kms';
import * as scheduler from 'aws-cdk-lib/aws-scheduler';
import * as sqs from 'aws-cdk-lib/aws-sqs';

declare const key: kms.Key;
declare const scheduleGroup: scheduler.CfnScheduleGroup;
Expand All @@ -1102,32 +1099,32 @@ const schedulerRole = new iam.Role(this, 'SchedulerRole', {
assumedBy: new iam.ServicePrincipal('scheduler.amazonaws.com'),
});
// To encrypt and decrypt the data
kmsKey.grantEncryptDecrypt(schedulerRole);
key.grantEncryptDecrypt(schedulerRole);
// To send the message to the queue
// This policy changes depending on the type of target.
schedulerRole.addToPrincipalPolicy(new iam.PolicyStatement({
actions: ['sqs:SendMessage'],
resources: [targetQueue.queueArn],
}));

const createScheduleTask1 = new EventBridgeSchedulerCreateScheduleTask(stack, 'createSchedule', {
const createScheduleTask1 = new tasks.EventBridgeSchedulerCreateScheduleTask(stack, 'createSchedule', {
scheduleName: 'TestSchedule',
actionAfterCompletion: ActionAfterCompletion.NONE,
actionAfterCompletion: tasks.ActionAfterCompletion.NONE,
clientToken: 'testToken',
description: 'TestDescription',
startDate: new Date(),
endDate: new Date(new Date().getTime() + 1000 * 60 * 60),
flexibleTimeWindow: cdk.Duration.minutes(5),
flexibleTimeWindow: Duration.minutes(5),
groupName: scheduleGroup.ref,
kmsKey,
kmsKey: key,
scheduleExpression: 'rate(5 minute)',
timezone: 'UTC',
enabled: true,
targetArn: targetQueue.queueArn,
role: schedulerRole,
retryPolicy: {
maximumRetryAttempts: 2,
maximumEventAge: cdk.Duration.minutes(5),
maximumEventAge: Duration.minutes(5),
},
deadLetterQueue,
});
Expand Down

0 comments on commit 6a21c6d

Please sign in to comment.