amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Export CDK doesn't work when stack contains imported auth

Open ilkerburakkurt opened this issue 3 years ago • 17 comments

Before opening, please confirm:

  • [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [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.

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)

# 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 (<anonymous>)
    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

ilkerburakkurt avatar Feb 15 '22 21:02 ilkerburakkurt

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 🙂

josefaidt avatar Feb 15 '22 22:02 josefaidt

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

ilkerburakkurt avatar Feb 16 '22 12:02 ilkerburakkurt

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

InnovateWithEric avatar Feb 16 '22 19:02 InnovateWithEric

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

TheRyanBurke avatar Mar 09 '22 20:03 TheRyanBurke

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)```

kplaricos avatar Jul 25 '22 10:07 kplaricos

Is there any update on this one please?

whisller avatar Aug 01 '22 13:08 whisller

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

valentinrelief avatar Sep 13 '22 21:09 valentinrelief

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

gabsn avatar Sep 28 '22 18:09 gabsn

Got the same issue as well here, amplify 10.0.0

lucadv avatar Sep 29 '22 10:09 lucadv

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.

dylm64 avatar Oct 26 '22 07:10 dylm64

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 :(

kalyanpenmetsa avatar Feb 15 '23 01:02 kalyanpenmetsa

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.

joekiller avatar May 31 '23 03:05 joekiller

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.

DarylSerrano avatar Nov 06 '23 12:11 DarylSerrano

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

josefaidt avatar Nov 16 '23 18:11 josefaidt

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

joekiller avatar Feb 16 '24 23:02 joekiller

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.

pr3tori4n avatar Apr 08 '24 21:04 pr3tori4n