Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Lambda Asset Results in Reduced Template #4927

Closed
markprovan opened this issue Nov 8, 2019 · 2 comments
Closed

Missing Lambda Asset Results in Reduced Template #4927

markprovan opened this issue Nov 8, 2019 · 2 comments
Assignees
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p0

Comments

@markprovan
Copy link

markprovan commented Nov 8, 2019

CDK reported a missing asset for a Lambda, correctly, but the deploy continued with a vastly reduced CloudFormation template, causing infrastructure to be torn down.

Reproduction Steps

Add a Lambda Function to a stack and reference an asset that does not exist as it's code parameter. Run cdk diff to see the resulting changes or cdk deploy to see this reproduced on a stack.

Error Log

Here is output from our CI job, showing the error, but continuing on to deployment

16:54:04  (node:176) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/var/lib/jenkins/workspace/ipa/redacted/@lambda-file.zip'
16:54:04      at Object.statSync (fs.js:855:3)
16:54:04      at Object.fingerprint (/var/lib/jenkins/workspace/ipa/redacted/node_modules/@aws-cdk/assets/lib/fs/fingerprint.ts:38:28)
16:54:04      at new Staging (/var/lib/jenkins/workspace/ipa/redacted/node_modules/@aws-cdk/assets/lib/staging.ts:58:23)
16:54:04      at new Asset (/var/lib/jenkins/workspace/ipa/redacted/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:95:21)
16:54:04      at AssetCode.bind (/var/lib/jenkins/workspace/ipa/redacted/node_modules/@aws-cdk/aws-lambda/lib/code.ts:180:20)
16:54:04      at new Function (/var/lib/jenkins/workspace/ipa/redacted/node_modules/@aws-cdk/aws-lambda/lib/function.ts:433:29)
16:54:04      at new AutomatedSnaphots (/var/lib/jenkins/workspace/ipa/redacted/src/stack/elasticsearch.ts:56:33)
16:54:04      at new InsightsElasticSearch (/var/lib/jenkins/workspace/ipa/insights-pipeline/apps/insights-pipeline/src/stack/elasticsearch.ts:220:9)
16:54:04      at new InsightsStack (/var/lib/jenkins/workspace/redacted/src/stack/stack.ts:68:55)
16:54:04      at /var/lib/jenkins/workspace/ipa/redacted/src/stack/app.ts:56:5
16:54:04  (node:176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
16:54:04  (node:176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
16:54:04  stack: deploying...
16:54:06  stack: creating CloudFormation changeset...

Environment

  • CLI Version 1.15.0 :
  • Framework Version: 1.15.0
  • OS :Centos 7
  • Language :

This is 🐛 Bug Report

@markprovan markprovan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 8, 2019
@SomayaB SomayaB added @aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-lambda Related to AWS Lambda labels Nov 8, 2019
@eladb eladb added the p0 label Nov 10, 2019
@eladb
Copy link
Contributor

eladb commented Nov 11, 2019

I am unable to reproduce this based on the instructions below. I consistently get the following error and the CLI immediately terminates with a non-zero exit code:

ENOENT: no such file or directory, stat '/Users/benisrae/playground/missing-asset/not-found'
Subprocess exited with error 1

Please reopen and provide exact CLI command you are running in your CI/CD system, and preferably also --verbose log of the CLI.

@eladb eladb closed this as completed Nov 11, 2019
@claabs
Copy link

claabs commented Jun 9, 2020

I was able to recreate this with a certain scenario. In my case, I import various configs dynamically, so I wrap the new Stack() in an async function:

async function main(): Promise<void> {
  const app = new cdk.App();
  const envProps = await envPropsFunc();
  const stack = new InfraStack(
    app, `InfraStack`,
    envProps
  );
}

main();

Under these circumstances, and the Lambda code asset missing, I see the deploy continue with a reduced template as described in the original post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p0
Projects
None yet
Development

No branches or pull requests

4 participants