From 726a3bed27cfe08584dd2ab8fa7fd0eab2dfae2a Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:48:01 -0700 Subject: [PATCH] chore: cleanup custom resource handler files (#30887) This PR cleans up the files created in a temp folder when the custom resource handlers are generated. While using a temp folder removes these files on restart, most people aren't typically in the habit of regular restarts. We are now in a position where running our integ tests and/or unit tests will cause my machine to run out of space. This is one of several PRs to fix this. This may seem like a tiny change to PR on it's own when I've just said that there will be several, but I'm intentionally keeping them small and separate. There is some behavior in our tests that I don't quite understand so small incremental change will help isolate this better. There are no tests to add here but I have run the entire test suite locally from a clean workspace after making this change. ### Checklist - [ ] 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* --- .../custom-resource-provider/custom-resource-provider-base.ts | 2 ++ .../custom-resource-provider/custom-resource-provider.test.ts | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider-base.ts b/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider-base.ts index 7bcc24269207f..eac5b161f3169 100644 --- a/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider-base.ts +++ b/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider-base.ts @@ -251,6 +251,8 @@ export abstract class CustomResourceProviderBase extends Construct { this._codeHash = staging.assetHash; + fs.rmSync(stagingDirectory, { recursive: true, force: true }); + return { code: { S3Bucket: asset.bucketName, diff --git a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts index f326e4b34ae07..6daa7c8b251a8 100644 --- a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts +++ b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts @@ -184,8 +184,6 @@ describe('custom resource provider', () => { const keyParam = paramNames[1]; const hashParam = paramNames[2]; - expect(fs.existsSync(path.join(sourcePath, '__entrypoint__.js'))).toEqual(true); - expect(cfn).toEqual({ Resources: { CustomMyResourceTypeCustomResourceProviderRoleBD5E655F: {