Skip to content

Commit

Permalink
feat(toolkit-cleaner): customizable timeout for asset cleaning Lambda…
Browse files Browse the repository at this point in the history
… functions (#291)

* feat(toolkit-cleaner): customizable timeout for asset cleaning Lambda functions

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

---------

Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
jogold and github-actions authored Nov 14, 2024
1 parent 1b68b28 commit 19aa403
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 14 additions & 0 deletions API.md

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

11 changes: 9 additions & 2 deletions src/toolkit-cleaner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export interface ToolkitCleanerProps {
* @default - all unused assets are removed
*/
readonly retainAssetsNewerThan?: Duration;

/**
* The timeout for the Lambda functions that clean assets
*
* @default Duration.minutes(5)
*/
readonly cleanAssetsTimeout?: Duration;
}

/**
Expand Down Expand Up @@ -102,7 +109,7 @@ export class ToolkitCleaner extends Construct {
});

const cleanObjectsFunction = new CleanObjectsFunction(this, 'CleanObjectsFunction', {
timeout: Duration.minutes(5),
timeout: props.cleanAssetsTimeout ?? Duration.minutes(5),
});
cleanObjectsFunction.addEnvironment('BUCKET_NAME', fileAsset.bucket.bucketName);
fileAsset.bucket.grantRead(cleanObjectsFunction);
Expand All @@ -113,7 +120,7 @@ export class ToolkitCleaner extends Construct {
});

const cleanImagesFunction = new CleanImagesFunction(this, 'CleanImagesFunction', {
timeout: Duration.minutes(5),
timeout: props.cleanAssetsTimeout ?? Duration.minutes(5),
});
cleanImagesFunction.addEnvironment('REPOSITORY_NAME', dockerImageAsset.repository.repositoryName);
dockerImageAsset.repository.grant(cleanImagesFunction, 'ecr:DescribeImages', 'ecr:BatchDeleteImage');
Expand Down

0 comments on commit 19aa403

Please sign in to comment.