首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Amplify:如何删除Auth并使用Api资源添加新的Auth资源。错误模板错误: Fn::GetAtt的实例引用了未定义的资源

Amplify:如何删除Auth并使用Api资源添加新的Auth资源。错误模板错误: Fn::GetAtt的实例引用了未定义的资源
EN

Stack Overflow用户
提问于 2021-09-17 06:56:34
回答 1查看 240关注 0票数 0

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

代码语言:javascript
复制
    ┌──────────┬───────────────┬───────────┬───────────────────┐
    │ Category │ Resource name │ Operation │ Provider plugin   │
    ├──────────┼───────────────┼───────────┼───────────────────┤
    │ Auth     │ testd50c8ec7  │ No Change │ awscloudformation │
    ├──────────┼───────────────┼───────────┼───────────────────┤
    │ Api      │ testApi       │ No Change │ awscloudformation │
    └──────────┴───────────────┴───────────┴───────────────────┘

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

代码语言:javascript
复制
Template error: instance of Fn::GetAtt references undefined resource testd50c8ec7

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

EN

回答 1

Stack Overflow用户

发布于 2021-09-17 06:56:34

我在这个问题上挣扎了很多天,所以我把这个答案打出来,以帮助我自己(和读者)在未来的几个小时里感到沮丧。

似乎一旦Api链接到Auth用户池配置,它总是需要可用的活动Auth Cognito用户池资源。因此,我需要按照以下步骤进行操作:

  1. 删除旧的身份验证

代码语言:javascript
复制
amplify remove auth

  1. ADD a new Auth resource

代码语言:javascript
复制
amplify add auth

您可以根据自己的喜好基于this AWS doc修改./backend/auth/<new resource name>/parameters.jsonbackend/auth/<new resource name>/<new resource name>-cloudformation-template.yml

对Api资源执行

  1. UPDATE操作,使其获得要创建的新身份验证名称。

代码语言:javascript
复制
% 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应该会显示如下内容:

代码语言:javascript
复制
┌──────────┬─────────────────┬───────────┬───────────────────┐
│ Category │ Resource name   │ Operation │ Provider plugin   │
├──────────┼─────────────────┼───────────┼───────────────────┤
│ Auth     │ test852bbeb0    │ Create    │ awscloudformation │
├──────────┼─────────────────┼───────────┼───────────────────┤
│ Api      │ testApi         │ Update    │ awscloudformation │
├──────────┼─────────────────┼───────────┼───────────────────┤
│ Auth     │ testd50c8ec7    │ Delete    │ awscloudformation │
└──────────┴─────────────────┴───────────┴───────────────────┘

  1. Now you amplify push没有错误或困难。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69219028

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档