aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 820 forks source link

Export CDK doesn't work when stack contains imported auth #9772

Open ilkerburakkurt opened 2 years ago

ilkerburakkurt commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

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

v14.18.0

Amplify CLI Version

7.6.19

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

Amplify Categories

auth

Amplify Commands

export

Describe the bug

When amplify backend stack contains imported auth (cognito user pool), amplify export command throws an error.

Expected behavior

CDK should be generated successfully.

Reproduction steps

  1. amplify init
  2. amplify import auth
  3. amplify export

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line βœ– Generating and writing root stack Cannot read property 'parameters' of undefined TypeError: Cannot read property 'parameters' of undefined at ResourceExport.fixNestedStackParameters (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/resource-package/resource-export.ts:102:59) at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/export-resources.ts:50:39) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5) at exportBackend (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/export.ts:74:5) at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/export.ts:62:5) at Object.executeAmplifyCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:373:5) at executePluginModuleCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:178:3) at executeCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:30:5) at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:205:5) ```

Additional information

No response

josefaidt commented 2 years ago

Hey @ilkerburakkurt :wave: thanks for taking the time to file this! I've marked this as a bug to log a more helpful error message when attempting to export a stack with imported auth πŸ™‚

ilkerburakkurt commented 2 years ago

Hi @josefaidt, If It could be able to export a reference to the resource as well, that would be fantastic.

InnovateWithEric commented 2 years ago

The fix here is to improve the error message from amplify export to message that export of imported auth is not supported.

TheRyanBurke commented 2 years ago

Is this true of any imported resource? Seeing this error message when exporting an Amplify project that imports DDB tables and S3 bucket, but not an auth module. TypeError: Cannot read property 'parameters' of undefined at ResourceExport.fixNestedStackParameters

kplaricos commented 2 years ago

Hi ! Have same issue as well with amplify cli 9.1.0.


πŸ›‘ Cannot read property 'parameters' of undefined
TypeError: Cannot read property 'parameters' of undefined
    at ResourceExport.fixNestedStackParameters (/snapshot/repo/build/node_modules/amplify-provider-awscloudformation/lib/resource-package/resource-export.js:144:59)
    at Object.run (/snapshot/repo/build/node_modules/amplify-provider-awscloudformation/lib/export-resources.js:94:39)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async exportBackend (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/export.js:86:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/export.js:74:9)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:292:9)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:165:13)```
whisller commented 2 years ago

Is there any update on this one please?

valentinrelief commented 1 year ago

Still getting this error:

βœ– Generating and writing root stack
πŸ›‘ Cannot read property 'parameters' of undefined
TypeError: Cannot read property 'parameters' of undefined
    at ResourceExport.fixNestedStackParameters (/snapshot/repo/build/node_modules/amplify-provider-awscloudformation/lib/resource-package/resource-export.js:144:59)
    at Object.run (/snapshot/repo/build/node_modules/amplify-provider-awscloudformation/lib/export-resources.js:94:39)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async exportBackend (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/export.js:86:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/export.js:74:9)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:292:9)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:165:13)

Could really use a better error message, updated documentation, or a workaround

gabsn commented 1 year ago

Same, amplify really sucks... I wish I could simply use the graphql transformer as part as my CDK...

lucadv commented 1 year ago

Got the same issue as well here, amplify 10.0.0

dylm64 commented 1 year ago

Hi @josefaidt, do you have any news on this ? we are facing the same issue with amplify 10.3.0 and 10.3.1. The issue is that we cannot really understand what is going wrong as the message is not informative and there is no exhaustive documentation and troubleshooting about the export. Also, the diagnose --send-report stop before sending, that reduce drastically the help we can receive.

kalyanpenmetsa commented 1 year ago

Was anyone able to find a work-around for this issue? I've invested a lot of time on building my app using amplify, and can't afford to abandon amplify altogether because of this :(

joekiller commented 1 year ago

The error is obscure:

βœ– Generating and writing root stack πŸ›‘ Cannot read properties of undefined (reading 'parameters')

During generating the root stack the error occurs because the nestedStack will not exist so .parameters is null. thus the error.

buildOverridesEnabledResources is only called during init with the context while during push it is called with both the context and a resource tree.

So being that push calls prepareBuildableResources which does the same 'packageResource' as packageBuildWriteResources does when it invokes packageResources, perhaps buildOverridesEnabledResources should be called after packageBuildWriteResources calls packageResources.

DarylSerrano commented 9 months ago

This is still not working in 12.7.1 Only way I have found to bypass this for s3 imported bucket is doing a amplify remove storage and making sure to not push those changes, then exporting it. But it would be great to have a export of reference to the resource.

josefaidt commented 9 months ago

Hey @DarylSerrano, @joekiller, and folks in the thread :wave: apologies for the delay here but I wanted to provide a quick update! Unfortunately amplify export does not currently support exporting when an imported resource exists in the project, and with this bug we aim to improve the error messaging to communicate this limitation.

Moving forward we will look into the suggested solution from @joekiller

joekiller commented 6 months ago

@josefaidt or @nadetastic with Dan's comment here, on #12631, it makes me think perhaps this isn't needed anymore? Could y'all give me a gut check. I haven't kept up much recently.

pr3tori4n commented 4 months ago

I'm seeing this error as well. Googling it got me here. The error message is still wholly ambiguous.

βœ– Generating and writing root stack
πŸ›‘ Cannot read properties of undefined (reading 'parameters')

I'd also like to request additional docs are added here to reference limitations like this.