aws-cdk: custom-resources integ tests failing
yarn integ currently fails in the @aws-cdk/custom-resources module with a cloudformation error.
Reproduction Steps
yarn install
cd packages/@aws-cdk/custom-resources
../../../scripts/buildup
yarn run integ
Error Log
5/9 | 9:09:36 PM | CREATE_FAILED | AWS::Lambda::Function | AWS679f53fac002430cb0da5b7982bd2287 (AWS679f53fac002430cb0da5b7982bd22872D164C4C) Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 7ad19cda-8432-4743-8473-7f4b292b8003)
new Function (/Users/valinm/dev/aws-cdk/packages/@aws-cdk/aws-lambda/lib/function.js:71:26)
\_ SingletonFunction.ensureLambda (/Users/valinm/dev/aws-cdk/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.js:37:16)
\_ new SingletonFunction (/Users/valinm/dev/aws-cdk/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.js:19:36)
\_ new AwsCustomResource (/Users/valinm/dev/aws-cdk/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.js:102:26)
\_ Object.<anonymous> (/Users/valinm/dev/aws-cdk/packages/@aws-cdk/custom-resources/test/aws-custom-resource/integ.aws-custom-resource.js:11:20)
\_ Module._compile (internal/modules/cjs/loader.js:776:30)
\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
\_ Module.load (internal/modules/cjs/loader.js:653:32)
\_ tryModuleLoad (internal/modules/cjs/loader.js:593:12)
\_ Function.Module._load (internal/modules/cjs/loader.js:585:3)
\_ Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
\_ startup (internal/bootstrap/node.js:283:19)
\_ bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Environment
- **CLI Version : 1.27.0 (current master)
- **Framework Version: 1.27.0 (current master)
- **OS : MacOS 10.14
- **Language : Typescript
Other
As far as I can tell, the code in custom-resources where this is coming from is pointing to an asset that has valid content. This could be an issue with assets.
recent assets change though not immediately clear if this is causing this. https://github.com/aws/aws-cdk/commit/d5575926b25cf0df8ea651041c426814153b6647
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- Revert "chore(cli): CLI uses `cdk-assets` to upload templates and assets (#6565)" (#6729) This reverts commit d5575926b25cf0df8ea651041c426814153b6647 due to a bug that blocks contributors from runni... — committed to aws/aws-cdk by deleted user 4 years ago
- chore(integ): consistently don't stage Staging was alternatively disabled and enabled for CDK apps during integ tests, depending on the execution phase. Make the flags consistently the same. This wou... — committed to aws/aws-cdk by rix0rrr 4 years ago
- chore(integ): consistently don't stage (#6769) * chore(integ): consistently don't stage Staging was alternatively disabled and enabled for CDK apps during integ tests, depending on the execution pha... — committed to aws/aws-cdk by rix0rrr 4 years ago
Thanks for debugging @jogold !
The problem is here: https://github.com/aws/aws-cdk/blob/8da9e1eb07e5cc60b421112df543b4bb9db703e8/packages/cdk-assets/lib/private/handlers/files.ts#L58
Here
this.workDiriscdk.outandthis.asset.source.pathis an absolute path to the asset. This result in a non-existant path and an empty zip file uploaded to S3.The
cdk.outcomes from herestack.assembly.directory: https://github.com/aws/aws-cdk/blob/8da9e1eb07e5cc60b421112df543b4bb9db703e8/packages/aws-cdk/lib/api/deploy-stack.ts#L132I would say that using
this.asset.source.pathincdk-assets/lib/private/handlers/files.tswould fix this since it’s an absolute path already… but from the JSDoc it’s expected to be relative…Note also that once you deployed it with an empty zip file it will always reuse that empty file unless you manually remove it from S3. https://github.com/aws/aws-cdk/blob/8da9e1eb07e5cc60b421112df543b4bb9db703e8/packages/cdk-assets/lib/private/handlers/files.ts#L38-L41
@rix0rrr
Cool. The solution seems to be to use
path.resolve()everywherepath.join()is being used.