Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify export to cdk is missing templateUrl property for one of nested stack #13297

Open
2 tasks done
0618 opened this issue Oct 3, 2023 · 2 comments
Open
2 tasks done
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working export Issues related to cdk-exported-backend p3

Comments

@0618
Copy link
Contributor

0618 commented Oct 3, 2023

How did you install the Amplify CLI?

npm

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

No response

Amplify CLI Version

12.2.3

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.

There's a work around by manually updating the generated root-stack-template.json. Adding
"TemplateURL": "https://s3.amazonaws.com/amplify-verifimeportalweb-dev-14927-deployment/amplify-cfn-templates/auth/auth-trigger-cloudformation-template.json ",
to AuthTriggerCustomLambdaStack.Properties.

Describe the bug

Exported backend to CDK fails to build when Lambda auth triggers are added.

Expected behavior

this should not require manual intervention and should function normally just like it would without the custom triggers being added

Reproduction steps

$ mkdir cdk-app
$ cd cdk-app
$ cdk init app --language typescript
$ cd ..
$ mkdir amplify-cdk
$ cd amplify-cdk
$ amplify init
$ amplify add auth >> add auth with a custom lambda trigger
$ amplify push --y
$ amplify export --out ../cdk-app/lib/
$ cd ../cdk-app
$ npm i @aws-amplify/cdk-exported-backend
$ npm i lodash
- Added below snippet to cdk-app/bin/cdk-app.ts
const amplifyStack = new AmplifyExportedBackend(app, "AmplifyExportedBackend", {
  path: path.resolve(__dirname, "../lib", "amplify-export-amplifycdk"),
  amplifyEnvironment: "dev",
});
$ cdk ls >> errors out due to missing templateUrl property

Project Identifier

No response

Log output

/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/core/lib/runtime.js:4
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
Error: VerifimePortalWebAmplifyExportedBackend-amplify-backend-stack/AmplifyCfnInclude/AuthTriggerCustomLambdaStack [AWS::CloudFormation::Stack] is missing required property: templateUrl
    at Object.requireProperty (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/core/lib/runtime.js:4:2814)
    at new CfnStack (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/core/lib/cloudformation.generated.js:1:51748)
    at Function._fromCloudFormation (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/core/lib/cloudformation.generated.js:1:51230)
    at CfnInclude.getOrCreateResource (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:12982)
    at new CfnInclude (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:2011)
    at new AmplifyExportedBackend (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/@aws-amplify/cdk-exported-backend/src/export-backend.ts:69:21)
    at Object.<anonymous> (/Users/charlesjiang/Work/verifyme-portal-web/cdk/verifime-cognito/bin/verifime-cognito.ts:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (/Users/charlesjiang/Work/verifyme-portal-web/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)

Subprocess exited with error 1


Additional information

worked around by updating the generated root-stack-template.json. Adding
"TemplateURL": "https://s3.amazonaws.com/amplify-verifimeportalweb-dev-14927-deployment/amplify-cfn-templates/auth/auth-trigger-cloudformation-template.json ",
to AuthTriggerCustomLambdaStack.Properties.

However, this should not require manual intervention and should function normally just like it would without the custom triggers being added

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@0618 0618 added the pending-triage Issue is pending triage label Oct 3, 2023
@ykethan ykethan added the export Issues related to cdk-exported-backend label Oct 3, 2023
@ykethan
Copy link
Member

ykethan commented Oct 3, 2023

Was able to reproduce the issue from the steps provided. marking as bug.

@ykethan ykethan added bug Something isn't working auth Issues tied to the auth category of the CLI and removed pending-triage Issue is pending triage labels Oct 3, 2023
@ykethan ykethan added p2 p3 and removed p2 labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working export Issues related to cdk-exported-backend p3
Projects
None yet
Development

No branches or pull requests

2 participants