aws / aws/aws-cdk-cli

core/assets: `cdk destroy` requires the deployment asset

Open
#822 11 comments 25 reactions 0 assignees View on GitHub
bug effort/small p1
Dominant language
TypeScript
Stars
105
Forks
122
Avg merge
1d 17h
Merged PRs (30d)
71

Description

### Describe the bug

Running `cdk destroy` with a Lambda function asset requires the deployment asset to be present. This seems counterintuitive at best and problematic in a variety of situations.

### Expected Behavior

`cdk destroy` should succeed, tear down the CF stack, undeploy the Lambda, etc. - no deployment asset should be needed.

### Current Behavior

```
2022-04-24.14:07:28 [STEP 1: Destroy the app] Destroying the application

/example-repo/environment/lambda/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:165
throw new Error(`Cannot find asset at ${this.sourcePath}`);
^
Error: Cannot find asset at /example-repo/environment/lambda/build/distributions/lambda-0.1.0-SNAPSHOT.zip
at new AssetStaging (/example-repo/environment/lambda/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:165:13)
at new Asset (/example-repo/environment/lambda/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.ts:131:21)
at AssetCode.bind (/example-repo/environment/lambda/node_modules/aws-cdk-lib/aws-lambda/lib/code.ts:282:20)
at new Function (/example-repo/environment/lambda/node_modules/aws-cdk-lib/aws-lambda/lib/function.ts:699:29)
at new LambdaStack (/example-repo/environment/lambda/lib/lambda-stack.ts:10:21)
at Object. (/example-repo/environment/lambda/bin/lambda.ts:7:1)
```

### Reproduction Steps

1. `cdk deploy` a stack that uses a Lambda asset
2. delete the asset
3. `cdk destroy` the stack

### Possible Solution

Don't look for the asset when destroying.

### Additional Information/Context

Using CDK TypeScript to deploy a Java Lambda asset

### CDK CLI Version

2.20.0 (build 738ef49)

### Framework Version

?

### Node.js Version

v16.14.2

### OS

Ubuntu 20.04.4 LTS

### Language

Typescript

### Language Version

TypeScript (~3.9.7)

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.