Delete schedules after execution #130
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When access is granted, an EventBridgeSchedule is created to fire when access should be revoked. However the schedules are not deleted, and so the list of schedules continues to grow, for ever.
This has the knock-on effect of making the revoke lambda run slower and slower, as it has to paginate through more and more old schedules.
This commit sets the ActionAfterCompletion property on the schedule so that once it has executed AWS will delete it. This means that the number of schedules should remain fairly constant over a given period of time.
Note that I have not included anything here to delete old schedules, so tidying-up an existing installation will be something that each team will need to perform manually.
Note
Sets ActionAfterCompletion=DELETE on all created EventBridge schedules so they are removed after firing.
ActionAfterCompletiontoDELETEfor schedules created in:schedule_revoke_eventschedule_group_revoke_eventschedule_discard_buttons_eventschedule_approver_notification_eventWritten by Cursor Bugbot for commit be0f8c1. This will update automatically on new commits. Configure here.