amazon-web-services - 如何根据 CloudFormation 上的条件更改属性?

标签 amazon-web-services aws-cloudformation amazon-cognito aws-userpools

我正在开发一个项目,根据开发环境,它将在 UserPoolClient 回调 URL 中显示不同的页面,但我遇到了以下错误:

Property validation failure: [Value of property {/CallbackURLs} does not match type {Array}]

我使用的代码如下,我不确定这是否是添加 if 条件的正确方法。我试图遵循 documentation但我没有 AWS 经验。

Conditions:
  IsProd: !Equals [ !Ref EnvType, 'prod']

  UserPoolApiClient:
    Type: AWS::Cognito::UserPoolClient
    Properties:
      ClientName: !Sub '${AWS::StackName}-user-pool-client'
      UserPoolId: !Ref UserPool
      GenerateSecret: false
      SupportedIdentityProviders:
        - COGNITO
      ExplicitAuthFlows:
        - USER_PASSWORD_AUTH
      CallbackURLs:
        !If
          - IsProd
          - Fn::Sub: '{!ImportValue landing-page}'
          - Fn::Sub: '{!ImportValue landing-page}/dev_welcome.html'

最佳答案

CallbackURLs 应该是一个列表:

      CallbackURLs:
        - !If
           - IsProd
           - Fn::Sub: '{!ImportValue landing-page}'
           - Fn::Sub: '{!ImportValue landing-page}/dev_welcome.html'

关于amazon-web-services - 如何根据 CloudFormation 上的条件更改属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70499949/

相关文章:

python - set_contents_from_string 在 S3 中上传时出现 AWS lambda_handler 错误

amazon-web-services - 在 aws lambda 更新过程中请求会发生什么情况?

amazon-web-services - AWS Cognito/Amplify 返回空刷新 token

amazon-web-services - 无需密码即可注册 AWS Cognito 以获取电子邮件确认链接

amazon-web-services - AWS Cloudformation - 使用安全组名称创建 EC2 实例

amazon-web-services - 在 eu-west-2 区域中使用 Terraform 时不会自动创建 Elastic Beanstalk 实例配置文件

amazon-web-services - 如何在安全组中添加source_security_group_id?

amazon-ec2 - 为什么我的 Ubuntu EC2 实例的 DataUser 部分中的脚本没有运行?我正在使用云信息

amazon-web-services - 无法在 Cloudformation 模板中为 AWS::ApiGateway::Resource 指定资源标识符

amazon-web-services - 云信息 : Error: Member must have length less than or equal to 20