简体   繁体   English

AWS Amplify 构建问题 - StackUpdateComplete

[英]AWS Amplify Build Issue - StackUpdateComplete

When running amplify push -y in the CLI, my project errors with this message:在 CLI 中运行amplify push -y时,我的项目出错并显示以下消息:

["Index: 0 State: {\"deploy\":\"waitingForDeployment\"} Message: Resource is not in the state stackUpdateComplete"]

How do I resolve this error?我该如何解决这个错误?

The "Resource is not in the state stackUpdateComplete" is the message that comes from the root CloudFormation stack associated with the Amplify App ID. “资源不在 state stackUpdateComplete 中”是来自与 Amplify App ID 关联的根 CloudFormation 堆栈的消息。 The Amplify CLI is just surfacing the error message that comes from the update stack operation. Amplify CLI 只是显示来自更新堆栈操作的错误消息。 This indicates that the Amplify's CloudFormation stack may have been still be in progress or stuck.这表明 Amplify 的 CloudFormation 堆栈可能仍在进行中或卡住了。

Solution 1 – “deployment-state.json”:解决方案 1 – “deployment-state.json”:

To fix this issue, go to the S3 bucket containing project settings and deleted the “deployment-state.json” file in root folder as this file holds the app deployment states.要解决此问题,请将 go 发送到包含项目设置的 S3 存储桶,并删除根文件夹中的“deployment-state.json”文件,因为该文件保存应用部署状态。 The bucket should end with, or contain the word “deployment”.存储桶应以“部署”一词结尾或包含“部署”一词。

Solution 2 – “Requested resource not found”:解决方案 2 – “未找到请求的资源”:

Check the status of the CloudFormation stack and see if you can notice that the stack failed because of a “Requested resource not found” error indicating that the DynamoDB table “tableID” was missing and confirm that you have deleted it (possibly accidentally).检查 CloudFormation 堆栈的状态,看看您是否注意到堆栈因“未找到请求的资源”错误而失败,表明 DynamoDB 表“tableID”丢失,并确认您已将其删除(可能是意外删除)。 Manually create the above DynamoDB table and retry to push again.手动创建上面的 DynamoDB 表并再次尝试推送。

Solution 3A - “@auth directive with 'apiKey':解决方案 3A - “带有‘apiKey’的@auth 指令:

If you recieve an error stating that “@auth directive with 'apiKey' provider found, but the project has no API Key authentication provider configured”.如果您收到一条错误消息,指出“找到带有‘apiKey’提供商的@auth 指令,但该项目没有配置 API 密钥身份验证提供商”。 This error appears when you define a public authorisation in your GraphQL schema without specifying a provider.当您在 GraphQL 模式中定义公共授权而不指定提供者时,会出现此错误。 The public authorization specifies that everyone will be allowed to access the API, behind the scenes the API will be protected with an API Key.公共授权指定每个人都将被允许访问 API,在幕后 API 将受到 API 密钥的保护。 To be able to use the public API you must have API Key configured.为了能够使用公共 API,您必须配置 API 密钥。

The @auth directive allows the override of the default provider for a given authorization mode. @auth 指令允许覆盖给定授权模式的默认提供程序。 To fix the issue specify “IAM” as the provider which allows to use an "Unauthenticated Role" from Cognito Identity Pools for public access instead of an API Key.要解决此问题,请将“IAM”指定为提供程序,它允许使用 Cognito 身份池中的“未经身份验证的角色”而不是 API 密钥进行公共访问。

Below is the sample code for public authorisation rule:下面是公共授权规则的示例代码:

type Todo @model @auth(rules: [{ allow: public, provider: iam, operations: [create, read, update, delete] }]) {
  id: ID!
  name: String!
  description: String
}

After making the above changes, you can run “amplify update api” and add a IAM auth provider, the CLI generated scoped down IAM policies for the "UnAuthenticated" role automatically.进行上述更改后,您可以运行“amplify update api”并添加 IAM 身份验证提供程序,CLI 会自动为“UnAuthenticated”角色生成范围缩小的 IAM 策略。

Solution 3B - Parameters: [AuthCognitoUserPoolId] must have values:解决方案 3B - 参数:[AuthCognitoUserPoolId] 必须具有以下值:

Another issue could occur here, where the default authorization type is API Key when you run the command “amplify add api” without specifying the API type.此处可能会出现另一个问题,默认授权类型为 API 密钥,当您运行命令“amplify add api”时未指定 API 类型。 To fix this issue, follow these steps:要解决此问题,请按照下列步骤操作:

  1. Deleted the the API删了 API
  2. Recreate a new one by specifying the “Amazon Cognito user pool” as the authorization mode通过将“Amazon Cognito 用户池”指定为授权模式来重新创建一个新的
  3. Add IAM as an additional authorization type添加 IAM 作为附加授权类型
  4. Re-enable @auth directive in the newly created API Schema在新创建的 API Schema 中重新启用 @auth 指令
  5. Run “amplify push”运行“放大推送”

Documentation:文档:

  1. Public Authorisation 公共授权
  2. Troubleshoot CloudFormation stack issues in my AWS Amplify project 排查我的 AWS Amplify 项目中的 CloudFormation 堆栈问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM