aws-amplify / aws-amplify/amplify-cli

env checkout is removing my 2nd dependency on storage

Open
#13,355 3 comments 0 reactions 0 assignees View on GitHub
bug p3 platform-push storage
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

v20.8.1

### Amplify CLI Version

12.6.0

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

### Describe the bug

I have storage and it has a trigger to the `videoTrigger` lambda function set up through the command line. Besides I added one more lambda function which is called `photoTrigger` and set-up by override.ts which adds perfect (After `amplify env checkout` it adds everything properly all properties to amplify/backend/storage/mystorage/build/cloudformation-template.json)

Since I added a second function as a trigger as well I am supposed to add a dependency on `backend-config.json` like this
```
"storage": {
"mystorage": {
"dependsOn": [
{
"attributes": [
"Name",
"Arn",
"LambdaExecutionRole"
],
"category": "function",
"resourceName": "videoTrigger"
},
{
"attributes": [
"Name",
"Arn",
"LambdaExecutionRole"
],
"category": "function",
"resourceName": "photoTrigger"
}
],
"providerPlugin": "awscloudformation",
"service": "S3"
}
}
```

However after `amplify env checkout dev` it removes my `photoTrigger` dependency. When I reversed functions (setup `photoTrigger` through the CLI and `videoTrigger` through the override.ts then it is removing `videoTrigger` one.

### Expected behavior

After checkout, it should not remove my second dependency.

### Reproduction steps

1. amplify add storage
2. Added a trigger
3. amplify storage override
4. create 2nd trigger with override.ts
5. amplify env checkout dev

### Project Identifier

12f0683bec31f5a654dd227fb4b63b53

### Log output

```
# Put your logs below this line

```

### Additional information

As I understood during the amplified checkout, for storage, it is removing all depends on and adding only the function that is added by cli. (I checked the 190th line of the amplify-cli/packages/amplify-category-storage/src/provider-utils/awscloudformation/cdk-stack-builder/s3-stack-builder.ts )

### Before submitting, please confirm:

- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

Contributor guide

Open the contributing guide

Research direction

Start in amplify-cli/packages/amplify-category-storage/src/provider-utils/awscloudformation/cdk-stack-builder/s3-stack-builder.ts, around the referenced line 190, and trace how amplify env checkout rebuilds storage dependencies. Reproduce with two storage triggers, one configured through the CLI and one through override.ts, then verify checkout preserves both photoTrigger and videoTrigger in backend-config.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
backend, cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.