Skip to content

Commit

Permalink
chore(scheduler-targets): lambda invoke target integration test (#27088)
Browse files Browse the repository at this point in the history
Continuing @Jacco work from #26268 

Currently we were second-guessing if the implementations of ScheduleExpression and ScheduleTargetInput generate valid and correct CloudFormation.

This integration test verifies that lambda invoke target is invoked:
- A schedule is deployed that triggers a Lambda every minute after deployment.
- The function adds a Tag to itself Key=OutputValue Value=base64 of the JSON string made of the input event
- An assertion is made that checks for 10 minutes if the expected Tag appears


Advances #23394

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
filletofish authored Sep 29, 2023
1 parent 20e4760 commit a1f2ec2
Show file tree
Hide file tree
Showing 14 changed files with 34,182 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import { ScheduleTargetBase, ScheduleTargetBaseProps } from './target';
import { sameEnvDimension } from './util';

/**
* Use an AWS Lambda function as a target for AWS EventBridge Scheduler.
*/
export class LambdaInvoke extends ScheduleTargetBase implements IScheduleTarget {
constructor(
private readonly func: lambda.IFunction,
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/lib/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export interface ScheduleTargetBaseProps {
readonly retryAttempts?: number;
}

/**
* Base class for Schedule Targets
*/
export abstract class ScheduleTargetBase {

constructor(
Expand Down Expand Up @@ -91,6 +94,11 @@ export abstract class ScheduleTargetBase {
};
}

/**
* Create a return a Schedule Target Configuration for the given schedule
* @param schedule
* @returnn
*/
bind(schedule: ISchedule): ScheduleTargetConfig {
return this.bindBaseTargetConfig(schedule);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-scheduler-targets-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
"@types/jest": "^29.5.5",
"aws-cdk-lib": "0.0.0",
"@aws-cdk/aws-scheduler-alpha": "0.0.0",
"constructs": "^10.0.0"
"constructs": "^10.0.0",
"@aws-cdk/integ-tests-alpha": "0.0.0"
},
"dependencies": {},
"peerDependencies": {
Expand Down
Loading

0 comments on commit a1f2ec2

Please sign in to comment.