【问题标题】:Amplify: How to remove Auth and add new Auth resource with Api resource. Error Template error: instance of Fn::GetAtt references undefined resource放大:如何删除 Auth 并使用 Api 资源添加新的 Auth 资源。错误模板错误:Fn::GetAtt 实例引用未定义资源
【发布时间】:2021-11-12 01:44:11
【问题描述】:

在放大中,我添加了 Api 和 Auth (AWS Cognito) 资源,如下所示。 Api 配置为使用 Auth Cognito 用户池进行身份验证。

    ┌──────────┬───────────────┬───────────┬───────────────────┐
    │ Category │ Resource name │ Operation │ Provider plugin   │
    ├──────────┼───────────────┼───────────┼───────────────────┤
    │ Auth     │ testd50c8ec7  │ No Change │ awscloudformation │
    ├──────────┼───────────────┼───────────┼───────────────────┤
    │ Api      │ testApi       │ No Change │ awscloudformation │
    └──────────┴───────────────┴───────────┴───────────────────┘

我仍在开发中,我想将 Auth (Cognito) 更改为使用电话号码登录。因此,我必须删除 Auth 并添加一个新的 Auth 资源(不允许使用电话登录更改现有用户池)。当我删除 Auth 资源并执行 amplify push 时。我收到一个错误:

Template error: instance of Fn::GetAtt references undefined resource testd50c8ec7

如何删除旧的并添加新的 Auth 资源?

【问题讨论】:

    标签: amazon-cognito aws-amplify aws-appsync


    【解决方案1】:

    我为此苦苦挣扎了很多天,所以我输入这个答案是为了帮助自己(和读者)在未来数小时内感到沮丧。

    似乎一旦 Api 链接到 Auth 用户池配置,它总是需要一个可用的活动 Auth Cognito 用户池资源。所以,我需要按顺序执行以下步骤:

    1. 删除旧的身份验证
    amplify remove auth
    
    1. 添加新的身份验证资源
    amplify add auth
    

    根据this AWS doc 随意修改./backend/auth/<new resource name>/parameters.jsonbackend/auth/<new resource name>/<new resource name>-cloudformation-template.yml 到您的喜好

    1. 更新 Api 资源,以便获取要创建的新身份验证名称。
    % amplify update api
    
    ? Please select from one of the below mentioned services: GraphQL
    ? Select from the options below Update auth settings
    ? Choose the default authorization type for the API Amazon Cognito User Pool
    Use a Cognito user pool configured as a part of this project.
    ? Configure additional auth types? Yes
    ? Choose the additional authorization types you want to configure for the API API key
    API key configuration
    ? Enter a description for the API key:
    ? After how many days from now the API key should expire (1-365): 7
    
    1. 现在,amplify status 应该显示如下内容:
    ┌──────────┬─────────────────┬───────────┬───────────────────┐
    │ Category │ Resource name   │ Operation │ Provider plugin   │
    ├──────────┼─────────────────┼───────────┼───────────────────┤
    │ Auth     │ test852bbeb0    │ Create    │ awscloudformation │
    ├──────────┼─────────────────┼───────────┼───────────────────┤
    │ Api      │ testApi         │ Update    │ awscloudformation │
    ├──────────┼─────────────────┼───────────┼───────────────────┤
    │ Auth     │ testd50c8ec7    │ Delete    │ awscloudformation │
    └──────────┴─────────────────┴───────────┴───────────────────┘
    
    1. 现在你 amplify push 没有错误或挣扎。

    【讨论】:

      猜你喜欢
      • 2017-06-10
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 2020-08-30
      • 1970-01-01
      • 2019-08-04
      • 1970-01-01
      相关资源
      最近更新 更多