aws-amplify / aws-amplify/amplify-cli

`amplify add storage` with an imported User Pool (no identity pool) errors with stack trace

Open
#13,240 10 comments 2 reactions 0 assignees View on GitHub
auth bug import p3 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?

pnpm

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

20.x

### Amplify CLI Version

12.4.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.

n/a

### Describe the bug

```
➜ amplify add storage
? Select from one of the below mentioned services: Content (Images, audio, video, etc.)
✔ Provide a friendly name for your resource that will be used to label this category in the project: · s36fd2fba9

✔ Provide bucket name: · importauthwithstorag3c42c9878f8744c7a9c5be63582
✔ Who should have access: · Auth users only
✔ What kind of access do you want for Authenticated users? · create/update
✔ Do you want to add a Lambda Trigger for your S3 Bucket? (y/N) · no
🛑 The imported auth config is not compatible with the specified storage config
🛑 An error occurred when adding the storage resource
ConfigurationError: The imported auth config is not compatible with the specified storage config
at checkStorageAuthenticationRequirements (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/provider-utils/awscloudformation/service-walkthroughs/s3-auth-api.js:45:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async addWalkthrough (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/provider-utils/awscloudformation/service-walkthroughs/s3-walkthrough.js:90:5)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/index.js:252:3)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
```

### Expected behavior

1. stack trace is not printed when running `amplify add storage`
```
🛑 The imported auth config is not compatible with the specified storage config
🛑 An error occurred when adding the storage resource
```
2. stack trace is printed when running `amplify add storage` with `--debug`
```
🛑 The imported auth config is not compatible with the specified storage config
🛑 An error occurred when adding the storage resource
ConfigurationError: The imported auth config is not compatible with the specified storage config
at checkStorageAuthenticationRequirements (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/provider-utils/awscloudformation/service-walkthroughs/s3-auth-api.js:45:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async addWalkthrough (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/provider-utils/awscloudformation/service-walkthroughs/s3-walkthrough.js:90:5)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-storage/lib/index.js:252:3)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
```
3. Auth configuration is validated at the start `amplify add storage` rather than at the end

### Reproduction steps

1. create an Amazon Cognito User Pool in the AWS Console
2. create a new Amplify project with `amplify init -y`
3. `amplify import auth` > Cognito User Pool only
4. `amplify add storage`
5. step through prompts
6. observe error

### Project Identifier

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

### 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 with checkStorageAuthenticationRequirements in service-walkthroughs/s3-auth-api.js and follow its call from s3-walkthrough.js during amplify add storage. Then inspect the error handling in cli-internal/execution-manager.js. Done means normal runs omit the stack trace, --debug includes it, and auth validation happens at the start of the walkthrough.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
authentication, cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.