Skip to content

Commit

Permalink
remove targetOverrides prop from Schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
samson-keung committed Oct 17, 2024
1 parent 7815144 commit 557fe80
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 321 deletions.
50 changes: 3 additions & 47 deletions packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as kms from 'aws-cdk-lib/aws-kms';
import { CfnSchedule } from 'aws-cdk-lib/aws-scheduler';
import { Construct } from 'constructs';
import { IGroup } from './group';
import { ScheduleTargetInput } from './input';
import { ScheduleExpression } from './schedule-expression';
import { IScheduleTarget } from './target';

Expand All @@ -26,37 +25,6 @@ export interface ISchedule extends IResource {
* The arn of the schedule.
*/
readonly scheduleArn: string;

/**
* The customer managed KMS key that EventBridge Scheduler will use to encrypt and decrypt your data.
*/
readonly key?: kms.IKey;
}

export interface ScheduleTargetProps {
/**
* The text, or well-formed JSON, passed to the target.
*
* If you are configuring a templated Lambda, AWS Step Functions, or Amazon EventBridge target,
* the input must be a well-formed JSON. For all other target types, a JSON is not required.
*
* @default - The target's input is used.
*/
readonly input?: ScheduleTargetInput;

/**
* The maximum amount of time, in seconds, to continue to make retry attempts.
*
* @default - The target's maximumEventAgeInSeconds is used.
*/
readonly maxEventAge?: Duration;

/**
* The maximum number of retry attempts to make before the request fails.
*
* @default - The target's maximumRetryAttempts is used.
*/
readonly retryAttempts?: number;
}

/**
Expand Down Expand Up @@ -115,11 +83,6 @@ export interface ScheduleProps {
*/
readonly target: IScheduleTarget;

/**
* Allows to override target properties when creating a new schedule.
*/
readonly targetOverrides?: ScheduleTargetProps;

/**
* The name of the schedule.
*
Expand Down Expand Up @@ -342,11 +305,9 @@ export class Schedule extends Resource implements ISchedule {
target: {
arn: targetConfig.arn,
roleArn: targetConfig.role.roleArn,
input: props.targetOverrides?.input ?
props.targetOverrides?.input?.bind(this) :
targetConfig.input?.bind(this),
input: targetConfig.input?.bind(this),
deadLetterConfig: targetConfig.deadLetterConfig,
retryPolicy: this.renderRetryPolicy(props.targetOverrides?.maxEventAge?.toSeconds(), props.targetOverrides?.retryAttempts),
retryPolicy: this.renderRetryPolicy(),
ecsParameters: targetConfig.ecsParameters,
kinesisParameters: targetConfig.kinesisParameters,
eventBridgeParameters: targetConfig.eventBridgeParameters,
Expand All @@ -366,14 +327,9 @@ export class Schedule extends Resource implements ISchedule {
});
}

private renderRetryPolicy(
maximumEventAgeInSeconds?: number,
maximumRetryAttempts?: number,
): CfnSchedule.RetryPolicyProperty | undefined {
private renderRetryPolicy(): CfnSchedule.RetryPolicyProperty | undefined {
const policy = {
...this.retryPolicy,
maximumEventAgeInSeconds: maximumEventAgeInSeconds ?? this.retryPolicy?.maximumEventAgeInSeconds,
maximumRetryAttempts: maximumRetryAttempts ?? this.retryPolicy?.maximumRetryAttempts,
};

if (policy.maximumEventAgeInSeconds && (policy.maximumEventAgeInSeconds < 60 || policy.maximumEventAgeInSeconds > 86400)) {
Expand Down
20 changes: 0 additions & 20 deletions packages/@aws-cdk/aws-scheduler-alpha/test/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,4 @@ describe('schedule target input', () => {
},
});
});

test('can override target input', () => {
// WHEN
const input = ScheduleTargetInput.fromText('Original Input');
new Schedule(stack, 'TestSchedule', {
schedule: expr,
target: new SomeLambdaTarget(func, input),
targetOverrides: {
input: ScheduleTargetInput.fromText('Overridden Input'),
},
enabled: false,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Scheduler::Schedule', {
Target: {
Input: '"Overridden Input"',
},
});
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@
"Properties": {
"Name": "TestGroup"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"UnnamedGroupBE3E48EE": {
"Type": "AWS::Scheduler::ScheduleGroup",
"Properties": {
"Name": "awscdkschedulerschedule-UnnamedGroup-97DBE50D"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"DefaultSchedule597B0B2C": {
"Type": "AWS::Scheduler::Schedule",
Expand Down Expand Up @@ -236,36 +236,6 @@
}
}
},
"TargetOverrideScheduleFF8CB184": {
"Type": "AWS::Scheduler::Schedule",
"Properties": {
"FlexibleTimeWindow": {
"Mode": "OFF"
},
"ScheduleExpression": "rate(12 hours)",
"ScheduleExpressionTimezone": "Etc/UTC",
"State": "ENABLED",
"Target": {
"Arn": {
"Fn::GetAtt": [
"Function76856677",
"Arn"
]
},
"Input": "\"Changed Text\"",
"RetryPolicy": {
"MaximumEventAgeInSeconds": 360,
"MaximumRetryAttempts": 5
},
"RoleArn": {
"Fn::GetAtt": [
"Role1ABCC5F0",
"Arn"
]
}
}
}
},
"AllSchedulerErrorsAlarmA3246F8C": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 557fe80

Please sign in to comment.