简体   繁体   中英

How to change a property depending on a condition on CloudFormation?

I am working on a project where depending on the development environment it will show a different page in a UserPoolClient callbackURL, but I had this error:

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

The code I used is like the following, I'm not sure if this is the correct way to add an if condition. I tried to follow the documentation but I don't have experience on 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 should be a list:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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