代码之家  ›  专栏  ›  技术社区  ›  Ryan Shillington

用一个Cognito池更新CloudFormation堆栈声称我们正在添加属性,而实际上我们没有

  •  1
  • Ryan Shillington  · 技术社区  · 6 年前

    Updating user pool schema is not allowed from cloudformation. Use the
    AddCustomAttributes API or the AWS Cognito Console to update user pool
    schema.
    

    我们的CF堆栈对Cognito池的自定义属性没有任何更改。它们只对 PostConfirmation CustomMessage 触发器,以及API网关响应的添加。

    3 回复  |  直到 6 年前
        1
  •  1
  •   SBond    6 年前

        2
  •  0
  •   Brad Flewelling    6 年前

    我们从模板中删除了CustomMessage更改,这似乎起到了作用。

        3
  •  0
  •   Ryan Shillington    6 年前

    幸运的是,我找到了一个答案,可以让我自动解决这个问题。

    首先,让我来解释一下这是怎么回事。我以前有以下一组cloudFormation脚本:

    cognitoSetup.template  --> <Serverless Framework> --> <cognitoSetup.template updated with triggers>
    

    因此,我们要设置cognoto池,运行Serverless框架来添加cognoto Lambda函数,然后用Serverless框架运行时导出的Lambda的arn更新cognosetup.template文件。

    修复

    cognitoSetup.template . 那么现在呢 cognitoSetup.template文件

       "CognitoUserPool": {
         "Type": "AWS::Cognito::UserPool"
         ...
         "Properties": {
         ...
         "LambdaConfig": {
            "CustomMessage": "arn:aws:lambda:<our aws region>:<our account#>:function:main-<our stage>-onCognitoCustomMessage"
          }
        }
    

    注意,我们正在设置触发器 之前 sls deploy 它创建了实际的Lambda函数,一切正常。

    现在我们的脚本如下所示:

    cognitoSetup.template  --> <Serverless Framework>
    

    为什么要修复此错误?我真的不知道。CloudFormation对这个修改似乎很好,但在我们的过程的后面修改同一个文件则不太好。但它是有效的。