AWS放大了由于aws-exports导致的部署失败 [英] AWS amplify deploy failure due to aws-exports
问题描述
我正在尝试将我的reactJs应用程序部署到Amplify.我将我的Github连接到Amplify.在部署过程中,它在构建"步骤中显示以下错误:
I am trying to deploy my reactJs app to Amplify. I have my Github connected to Amplify. During deployment it shows the following error at Build step:
2020-01-07T19:35:22.127Z [INFO]: Failed to compile.
2020-01-07T19:35:22.129Z [INFO]: ./src/index.js
Cannot find file './aws-exports' in './src'.
2020-01-07T19:35:22.149Z [WARNING]: error Command failed with exit code 1.
2020-01-07T19:35:22.150Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020-01-07T19:35:22.155Z [ERROR]: !!! Build failed
2020-01-07T19:35:22.239Z [ERROR]: !!! Non-Zero Exit Code detected
2020-01-07T19:35:22.239Z [INFO]: # Starting environment caching...
之所以会这样,是因为.gitignore
会忽略aws-exports.
有人可以告诉我不提交aws-exports来解决此问题的解决方案吗?
This happens because .gitignore
ignores aws-exports.
Can someone please tell me what's the solution to this problem without committing aws-exports?
推荐答案
我在第一个版本中遇到了相同的问题.由于aws-exports
包含敏感信息,因此可以将其添加到.gitignore文件中.
I have experienced the same problem in my first build. Since aws-exports
contains sensitive information you are right by adding it to your .gitignore file.
Amplify文档并未具体说明使用Amplify Console时应如何维护构建,但是对我有用的例程是:
The Amplify documentation is not specific about how you should maintain your builds when using the Amplify Console, but the routine that worked for me was:
运行成功的amplify push
命令时,将生成aws-exports
文件.
You generate your aws-exports
file when you run a successful amplify push
command.
aws-exports.js文件 该文件仅针对JavaScript生成 项目.它包含所有类别的合并输出 并放置在用户(开发人员)的src目录下 在初始化过程中指定.每次成功后都会更新 执行已经创建或更新了命令amplify push的命令 云资源.
aws-exports.js file This file is generated only for JavaScript projects. It contains the consolidated outputs from all the categories and is placed under the src directory that the user (the developer) specified during the init process. It is updated after each successful execution of the amplify push command, that has created or updated the cloud resources.
基于此,我在Amplify控制台中更新了我的配置,以同时部署我的后端.您可以在 https://docs上了解如何配置自己的文件. aws.amazon.com/amplify/latest/userguide/build-settings.html
Based on that I updated my configuration in the Amplify console to also deploy my backend. You can learn how to configure your own at https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
完成后端构建后,将为我的下一个作业生成文件,这是消耗aws-exports
文件的前端构建.
After the backend build is done the file is generated for my next job which is the frontend build that consumes the aws-exports
file.
注意:如果您使用的是eslint,则文件输出格式可能会出现问题.您可以在前端preBuild
Note: If you're using eslint you can have a problem with the file output format. You can add a eslint --fix
command in your frontend preBuild
我使用的来源: - https://aws-amplify.github.io/docs/cli-toolchain/usage#aws-exportsjs-file
Sources I used: - https://aws-amplify.github.io/docs/cli-toolchain/usage#aws-exportsjs-file
这篇关于AWS放大了由于aws-exports导致的部署失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!