Good day, first time posting to github. I appreciate your help.
Describe the bug
When trying to apply 'amplify push' command I get the following error:
(... to anonymize examples)
Only one CloudFormation template is allowed in the resource directory
C:\ ... \amplify\backend\function\awsauthexample123456
脳 An error occurred when pushing the resources to the cloud
Only one CloudFormation template is allowed in the resource directory
An error occured during the push operation: Only one CloudFormation template is allowed in the resource directory
_Is there a way to manually clean up these CloudFormation templates as a temporary fix..?_
Amplify CLI Version
4.17.1
To Reproduce
I am using this example repository:
https://github.com/ErikCH/Aws-auth-example.git
and following this tutorial
https://www.youtube.com/watch?v=DFftniOvoLA
These commands:
git clone https://github.com/ErikCH/Aws-auth-example.git Aws-auth-example
npm install
npm install aws-amplify aws-amplify-vue@beta
npm audit fix
npm install -g @aws-amplify/cli
amplify configure
amplify init
amplify add auth (follow defaults)
amplify add function (follow defaults, except choose 'Serverless ExpressJS function (integration with API Gateway)
amplify function build
amplify push
I also had this problem with custom code, but I believe it would be easier to reproduce with the information provided above.
This problem also occurs with trying to use more specific push commands like 'amplify function push' or 'amplify api push'
Expected behavior
When I perform 'amplify configure' and 'amplify init' the initial resources such as shown in the initial screen shot below are created successfully. I would expect the same to happen with 'amplify push' or 'amplify publish'
Screenshots
These are the initial resources added, but I can't seem to push any more after 'amplify init' is applied:

Desktop (please complete the following information):
Additional context
I am trying to build a VueJS single page application.
Using the command 'amplify function push' provides a more verbose but similar error:
Only one CloudFormation template is allowed in the resource directory
C:\ ... \amplify\backend\function\awsauthexample123456
脳 An error occurred when pushing the resources to the cloud
Only one CloudFormation template is allowed in the resource directory
Error: Only one CloudFormation template is allowed in the resource directory
at C:\ ... \npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\push-resources.js:244:17
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async Promise.all (index 0)
at Object.run (C: ... \npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\push-resources.js:37:5)
at async Promise.all (index 0)
at providersPush (C: ... \npm\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\push-resources.js:86:3)
at AmplifyToolkit.pushResources [as _pushResources] (C: ... \npm\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\push-resources.js:63:7)
at Object.executeAmplifyCommand (C:\ ... \npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-function\src\index.ts:131:3)
at executePluginModuleCommand (C:\ ... \npm\node_modules\@aws-amplify\cli\src\execution-manager.ts:158:7)
An error occurred when pushing the function resource
I also receive this error when trying to add the function, but this error doesn't appear fatal and my local versions are created.
(node:10548) UnhandledPromiseRejectionWarning: Error: ENOENT:
no such file or directory, stat '/C:\...\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-function\lib\provider-utils/../../resources/awscloudformation/cloudformation-templates/lambda-cloudformation-template.json.ejs'
at Object.statSync (fs.js:915:3)
at Object.statSync (C:...\npm\node_modules\@aws-amplify\cli\node_modules\graceful-fs\polyfills.js:308:16)
at Object.isFile (C:\...\npm\node_modules\@aws-amplify\cli\lib\context-extensions.js:136:43)
at Object.generate (C:\...\npm\node_modules\@aws-amplify\cli\lib\context-extensions.js:279:36)
at AmplifyToolkit.copyBatch [as _copyBatch] (C:\...\npm\node_modules\@aws-amplify\cli\lib\extensions\amplify-helpers\copy-batch.js:17:22)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:10548) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection
id: 1)
(node:10548) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I produced the same error using this repository too:
https://github.com/aws-samples/cloudfront-authorization-at-edge.git
but I was able to adding S3cloudfront hosting and push without error. Then added a function and got the error when I tried to push.
I ran 'amplify delete'. Tried to push a new function. and received the error again. In summary the error appears to be tied to pushing new functions.
Hi.
I
I am having the same errors:
After I added a new Function, I get that error on the last step, right before amplify asks me to open in editor:
Do you want to edit the local lambda function now? (Y/n) (node:15984) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-function\lib\provider-utils/../../resources/awscloudformation/cloudformation-templates/lambda-cloudformation-template.json.ejs'
at Object.statSync (fs.js:856:3)
at Object.statSync (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\graceful-fs\polyfills.js:308:16)
at Object.isFile (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\lib\context-extensions.js:136:43)
at Object.generate (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\lib\context-extensions.js:279:36)
at AmplifyToolkit.copyBatch [as _copyBatch] (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\lib\extensions\amplify-helpers\copy-batch.js:17:22)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:15984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15984) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
? Do you want to edit the local lambda function now? Yes
And if I try to push the functions anyway, I am getting this error:
Error: Only one CloudFormation template is allowed in the resource directory
at C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\push-resources.js:244:17
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Promise.all (index 0)
at Object.run (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\push-resources.js:37:5)
at async Promise.all (index 0)
at providersPush (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\push-resources.js:86:3)
at AmplifyToolkit.pushResources [as _pushResources] (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\push-resources.js:63:7)
at Object.executeAmplifyCommand (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-function\src\index.ts:131:3)
at executePluginModuleCommand (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\src\execution-manager.ts:158:7)
at Object.executeCommand (C:\Users\Luigi\AppData\Roaming\npm\node_modules\@aws-amplify\cli\src\execution-manager.ts:24:5)
An error occurred when pushing the function resource
The amplify push was working OK before adding a new function.
I am using this version:
amplify -v
4.17.1
This was a windows issue caused by incorrect path concatenation. Fixed in the PR above