-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(scheduler-alpha): target properties override #27603
Conversation
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Exemption Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lpizzinidev! Super minor comments, otherwise i think we are gtg
* | ||
* @default - The target's maximumEventAgeInSeconds is used. | ||
*/ | ||
readonly maximumEventAge?: Duration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's called maxEventAge
in schedule-targets
, lets call it that here too
* | ||
* @default - The target's input is used. | ||
*/ | ||
readonly input?: ScheduleTargetInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly input?: ScheduleTargetInput; | |
readonly input?: ScheduleTargetInput; | |
* | ||
* @default - The target's maximumEventAgeInSeconds is used. | ||
*/ | ||
readonly maximumEventAge?: Duration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly maximumEventAge?: Duration; | |
readonly maximumEventAge?: Duration; | |
* | ||
* @default - The target's maximumRetryAttempts is used. | ||
*/ | ||
readonly maximumRetryAttempts?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly maximumRetryAttempts?: number; | |
readonly maxRetryAttempts?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to retryAttempts
as in target class.
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nit @lpizzinidev
@@ -256,8 +256,22 @@ const target = new targets.LambdaInvoke(fn, { | |||
|
|||
## Overriding Target Properties | |||
|
|||
TODO: Not yet implemented. See section in [L2 Event Bridge Scheduler RFC](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0474-event-bridge-scheduler-l2.md) | |||
If you wish to reuse the same target in multiple schedules, you can override target properties like `input`, | |||
`maximumRetryAttempts` and `maximumEventAgeInSeconds` when creating a Schedule using the `targetOverrides` parameter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`maximumRetryAttempts` and `maximumEventAgeInSeconds` when creating a Schedule using the `targetOverrides` parameter: | |
`retryAttempts` and `maxEventAge` when creating a Schedule using the `targetOverrides` parameter: |
schedule: ScheduleExpression.rate(cdk.Duration.hours(12)), | ||
target, | ||
targetOverrides: { | ||
input: ScheduleTargetInput.fromText("Overriding Target Input"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input: ScheduleTargetInput.fromText("Overriding Target Input"), | |
input: ScheduleTargetInput.fromText('Overriding Target Input'), |
deadLetterConfig: targetConfig.deadLetterConfig, | ||
retryPolicy: targetConfig.retryPolicy, | ||
retryPolicy: retryPolicy.maximumEventAgeInSeconds || retryPolicy.maximumRetryAttempts ? retryPolicy : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, it's unnecessarily complicated. And what if we add a prop to retryPolicy
in the future? Lets add a function that creates a retryPolicy but returns undefined if no properties inside the object are defined
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Pull request has been modified.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Allows to override a `Schedule` target's properties. Supported properties: `input`, `maxEventAge`, and `retryAttempts`. Example: ```ts declare const target: targets.LambdaInvoke; const oneTimeSchedule = new Schedule(this, 'Schedule', { schedule: ScheduleExpression.rate(cdk.Duration.hours(12)), target, targetOverrides: { input: ScheduleTargetInput.fromText("Overriding Target Input"), maxEventAge: Duration.seconds(180), retryAttempts: 5, }, }); ``` Closes #27545. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Allows to override a
Schedule
target's properties.Supported properties:
input
,maxEventAge
, andretryAttempts
.Example:
Closes #27545.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license