aws / aws/aws-cdk

(amplify-alpha): CDK wants to zip and upload whole project folder

Open
#29,163 5 comments 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-amplify bug effort/medium p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

A cdk deploy run tries to zip and upload the whole project folder including .git, node_modules, etc.

### Expected Behavior

Only the Asset itself is zipped and uploaded, not the whole project folder.

### Current Behavior

I'm working on a CDK monorepo project, so the frontend is only a part of the project.

The structure of the project looks like this:
packages\module

Where module is a Lambda, API Gateway, whatever and the Vue.js frontend.

So the frontend is located in packages\vue-frontend.

Currently, the frontend is build locally and is available in packages\vue-frontend\dist for the cdk deploy run. The current version uses a BucketDeployment to upload the files and the frontend is published using CloudFront. This works fine so far.

Now there is the requirement to use Amplify to host the frontend. So the idea is to use amplify-alpha to use an Asset to upload the static frontend build. Unfortunately, using GitHub, GitLab or CodeCommit isn't an option so I can't rely on a SourceCodeProvider.

[16:35:46] my-project: build: Zip C:\Users\Aldjinn\Projects\my-project -> C:\Users\wilm028\Projects\my-project\cdk.out\.cache\acbcce3d7c7707096b4a0d04c139c1f2d642d3757294ce0d1ba609b00a31d91a.zip

This file ends up with > 2 GB, if the zip even finishes.

### Reproduction Steps

```
const amplifyApp = new App(this, 'MyApp', {
appName: "my-app",
});

const asset = new assets.Asset(this, 'SampleAsset', {
path: path.join(__dirname, 'dist'),
});

const branch = amplifyApp.addBranch('dev', {
asset: asset,
});
```

The problem is only triggered when Branch and Asset are added. Without these, everything works fine.

### Possible Solution

_No response_

### Additional Information/Context

The required zip for the Asset is created. But I don't understand, which part of my project triggers this big zip of the whole project folder.

### CDK CLI Version

2.128.0 (build d995261)

### Framework Version

2.128.0-alpha.0

### Node.js Version

v18.19.1

### OS

Windows 11 22H2

### Language

TypeScript

### Language Version

5.2.2

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the cdk deploy reproduction using App, assets.Asset, and amplifyApp.addBranch, with the asset at packages/vue-frontend/dist. Trace why adding the Branch and Asset causes the project root to be zipped; done means deployment packages only the frontend asset rather than .git, node_modules, and the rest of the project.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.