Skip to content

Commit

Permalink
chore(scheduler-alpha): make LambdaInvoke prop optional (#31887)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

None.

### Reason for this change

Improve ergonomics of the `LambdaInvoke` constructor signature. The second argument is not required so we should not force customers to pass in an empty object.

### Description of changes

Make the `LambdaInvoke` `prop` argument default to empty object.

### Description of how you validated changes

Unit test updated to omit the `prop` argument if no props are being passed.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
samson-keung authored Oct 24, 2024
1 parent 4f29c1d commit 732f458
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class LambdaInvoke extends ScheduleTargetBase implements IScheduleTarget

constructor(
func: lambda.IFunction,
props: ScheduleTargetBaseProps,
props: ScheduleTargetBaseProps = {},
) {
super(props, func.functionArn);
this.func = func;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('schedule target', () => {
});

test('creates IAM role and IAM policy for lambda target in the same account', () => {
const lambdaTarget = new LambdaInvoke(func, {});
const lambdaTarget = new LambdaInvoke(func);

new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('schedule target', () => {
const lambdaVersion = new lambda.Version(stack, 'MyLambdaVersion', {
lambda: func,
});
const lambdaTarget = new LambdaInvoke(lambdaVersion, {});
const lambdaTarget = new LambdaInvoke(lambdaVersion);

new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
Expand Down Expand Up @@ -250,7 +250,7 @@ describe('schedule target', () => {
test('creates IAM policy for imported lambda function in the same account', () => {
const importedFunc = lambda.Function.fromFunctionArn(stack, 'ImportedFunction', 'arn:aws:lambda:us-east-1:123456789012:function/somefunc');

const lambdaTarget = new LambdaInvoke(importedFunc, {});
const lambdaTarget = new LambdaInvoke(importedFunc);

new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('schedule target', () => {
aliasName: 'SomeAliasName',
});

const lambdaTarget = new LambdaInvoke(lambdaAlias, {});
const lambdaTarget = new LambdaInvoke(lambdaAlias);

new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('schedule target', () => {
},
);

const lambdaTarget = new LambdaInvoke(importedFunc, {});
const lambdaTarget = new LambdaInvoke(importedFunc);
new Schedule(stack, 'MyScheduleDummy', {
schedule: expr,
target: lambdaTarget,
Expand Down

0 comments on commit 732f458

Please sign in to comment.