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: {