试图让 Amplify CI/CD 发布流程部署到单独的 AWS 账户
Trying to get the Amplify CI/CD release process to deploy to a separate AWS account
我正在尝试让 CI/CD 发布流程正常工作,以便当我提交到发布分支时,它会运行放大推送流程。
我 AM 能够在本地 amplify push
没有任何问题(在切换分支并检查正确的放大环境之后)。
此应用程序有两个环境:'staging' 和 'live'。对于这些环境,我有两个单独的 AWS 账户。我最初在暂存阶段创建并测试了该项目。测试完成后,我创建了一个新的 AWS 账户,创建了一个新的 Amplify 项目,并将其连接到我的存储库中的 'live' 分支。
当我将提交推送到 'live' 分支时,它会开始构建,并完成配置和预构建阶段。然后我得到这个:
# Starting phase: build
2022-04-06T17:57:48.997Z [INFO]: Amplify AppID found: xxxxxxxxxxxx. Amplify App name is: Project Production
2022-04-06T17:57:49.080Z [INFO]: Backend environment live found in Amplify Console app: Project Production
2022-04-06T17:57:56.229Z [WARNING]: - Fetching updates to backend environment: live from the cloud.
2022-04-06T17:58:02.363Z [WARNING]: - Building resource api/myapi
2022-04-06T17:58:13.032Z [INFO]: GraphQL schema compiled successfully.
Edit your schema at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema.graphql or place .graphql files in a directory at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema
2022-04-06T17:58:13.033Z [WARNING]: - Building resource api/restapi
2022-04-06T17:58:17.485Z [WARNING]: - Building resource custom/MagicLinkEmailTemplate
2022-04-06T17:58:17.486Z [WARNING]: - Building custom resources
2022-04-06T17:58:32.284Z [WARNING]: - Building resource custom/MyCustomResource
- Building custom resources
2022-04-06T17:58:48.882Z [WARNING]: - Building resource custom/MyStateMachine
2022-04-06T17:58:48.883Z [WARNING]: - Building custom resources
2022-04-06T17:59:04.647Z [WARNING]: - Building resource custom/HostedZone
- Building custom resources
2022-04-06T17:59:23.823Z [WARNING]: ✔ Successfully pulled backend environment live from the cloud.
2022-04-06T17:59:23.934Z [INFO]:
2022-04-06T17:59:25.368Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2022-04-06T17:59:27.068Z [WARNING]: - Initializing your environment: live
2022-04-06T17:59:33.150Z [WARNING]: - Building resource api/myapi
2022-04-06T17:59:39.389Z [INFO]: GraphQL schema compiled successfully.
Edit your schema at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema.graphql or place .graphql files in a directory at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema
2022-04-06T17:59:39.390Z [WARNING]: - Building resource api/restapi
2022-04-06T17:59:43.825Z [WARNING]: - Building resource custom/MagicLinkEmailTemplate
2022-04-06T17:59:43.828Z [WARNING]: - Building custom resources
2022-04-06T17:59:50.278Z [WARNING]: - Building resource custom/MyCustomResource
- Building custom resources
2022-04-06T17:59:58.898Z [WARNING]: - Building resource custom/MyStateMachine
- Building custom resources
2022-04-06T18:00:06.435Z [WARNING]: - Building resource custom/HostedZone
- Building custom resources
2022-04-06T18:00:16.067Z [WARNING]: ✔ Initialized provider successfully.
2022-04-06T18:00:17.268Z [INFO]:
2022-04-06T18:00:17.274Z [INFO]: Suggested configuration for new layer versions:
2022-04-06T18:00:17.282Z [INFO]: myappLayerGraphQL
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerAxios
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerLodash
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerStripe
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
2022-04-06T18:00:17.282Z [INFO]:
2022-04-06T18:00:31.140Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2022-04-06T18:00:31.162Z [WARNING]: ✖ There was an error initializing your environment.
2022-04-06T18:00:31.170Z [INFO]: Error: Packaging lambda function failed with the error
Command failed with exit code 1: npm install --production
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/language/directiveLocation.mjs'
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/type/directives.mjs'
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/execution/execute.mjs'
......
这些错误持续了大约 400 行...
我不知道那个 .staging 目录是什么,也不知道它来自哪里——它不在我的实际图层中,我在整个图层目录的任何文件中都没有看到对 'staging' 的引用.
有什么帮助吗?!
Amplify 中发生了一些变化,我开始收到不同的错误消息,这让我找到了解决方案。
事实证明,我没有正确授权构建过程来安装我在 GitHub 包管理器上的私有 NPM 包。我将本地用户目录中的 .npmrc
文件放到包含失败函数的 package.json
的目录中,然后它开始工作。
糟糕的错误记录使简单的解决方案变得更加困难...
我正在尝试让 CI/CD 发布流程正常工作,以便当我提交到发布分支时,它会运行放大推送流程。
我 AM 能够在本地 amplify push
没有任何问题(在切换分支并检查正确的放大环境之后)。
此应用程序有两个环境:'staging' 和 'live'。对于这些环境,我有两个单独的 AWS 账户。我最初在暂存阶段创建并测试了该项目。测试完成后,我创建了一个新的 AWS 账户,创建了一个新的 Amplify 项目,并将其连接到我的存储库中的 'live' 分支。
当我将提交推送到 'live' 分支时,它会开始构建,并完成配置和预构建阶段。然后我得到这个:
# Starting phase: build
2022-04-06T17:57:48.997Z [INFO]: Amplify AppID found: xxxxxxxxxxxx. Amplify App name is: Project Production
2022-04-06T17:57:49.080Z [INFO]: Backend environment live found in Amplify Console app: Project Production
2022-04-06T17:57:56.229Z [WARNING]: - Fetching updates to backend environment: live from the cloud.
2022-04-06T17:58:02.363Z [WARNING]: - Building resource api/myapi
2022-04-06T17:58:13.032Z [INFO]: GraphQL schema compiled successfully.
Edit your schema at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema.graphql or place .graphql files in a directory at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema
2022-04-06T17:58:13.033Z [WARNING]: - Building resource api/restapi
2022-04-06T17:58:17.485Z [WARNING]: - Building resource custom/MagicLinkEmailTemplate
2022-04-06T17:58:17.486Z [WARNING]: - Building custom resources
2022-04-06T17:58:32.284Z [WARNING]: - Building resource custom/MyCustomResource
- Building custom resources
2022-04-06T17:58:48.882Z [WARNING]: - Building resource custom/MyStateMachine
2022-04-06T17:58:48.883Z [WARNING]: - Building custom resources
2022-04-06T17:59:04.647Z [WARNING]: - Building resource custom/HostedZone
- Building custom resources
2022-04-06T17:59:23.823Z [WARNING]: ✔ Successfully pulled backend environment live from the cloud.
2022-04-06T17:59:23.934Z [INFO]:
2022-04-06T17:59:25.368Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2022-04-06T17:59:27.068Z [WARNING]: - Initializing your environment: live
2022-04-06T17:59:33.150Z [WARNING]: - Building resource api/myapi
2022-04-06T17:59:39.389Z [INFO]: GraphQL schema compiled successfully.
Edit your schema at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema.graphql or place .graphql files in a directory at /codebuild/output/src656745275/src/project-name/amplify/backend/api/myapi/schema
2022-04-06T17:59:39.390Z [WARNING]: - Building resource api/restapi
2022-04-06T17:59:43.825Z [WARNING]: - Building resource custom/MagicLinkEmailTemplate
2022-04-06T17:59:43.828Z [WARNING]: - Building custom resources
2022-04-06T17:59:50.278Z [WARNING]: - Building resource custom/MyCustomResource
- Building custom resources
2022-04-06T17:59:58.898Z [WARNING]: - Building resource custom/MyStateMachine
- Building custom resources
2022-04-06T18:00:06.435Z [WARNING]: - Building resource custom/HostedZone
- Building custom resources
2022-04-06T18:00:16.067Z [WARNING]: ✔ Initialized provider successfully.
2022-04-06T18:00:17.268Z [INFO]:
2022-04-06T18:00:17.274Z [INFO]: Suggested configuration for new layer versions:
2022-04-06T18:00:17.282Z [INFO]: myappLayerGraphQL
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerAxios
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerLodash
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
myappLayerStripe
- Access permissions: Maintain existing permissions
- Description: Updated layer version 2022-04-06T18:00:17.273Z
2022-04-06T18:00:17.282Z [INFO]:
2022-04-06T18:00:31.140Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2022-04-06T18:00:31.162Z [WARNING]: ✖ There was an error initializing your environment.
2022-04-06T18:00:31.170Z [INFO]: Error: Packaging lambda function failed with the error
Command failed with exit code 1: npm install --production
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/language/directiveLocation.mjs'
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/type/directives.mjs'
npm WARN tar ENOENT: no such file or directory, open '/codebuild/output/src656745275/src/project-name/amplify/backend/function/myappLayerGraphQL/lib/nodejs/node_modules/.staging/graphql-03f7efb5/execution/execute.mjs'
......
这些错误持续了大约 400 行...
我不知道那个 .staging 目录是什么,也不知道它来自哪里——它不在我的实际图层中,我在整个图层目录的任何文件中都没有看到对 'staging' 的引用.
有什么帮助吗?!
Amplify 中发生了一些变化,我开始收到不同的错误消息,这让我找到了解决方案。
事实证明,我没有正确授权构建过程来安装我在 GitHub 包管理器上的私有 NPM 包。我将本地用户目录中的 .npmrc
文件放到包含失败函数的 package.json
的目录中,然后它开始工作。
糟糕的错误记录使简单的解决方案变得更加困难...