Skip to content

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

@0618

Description

@0618

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

Details
/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues tied to the auth category of the CLIbugSomething isn't workingexportIssues related to cdk-exported-backendp3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions