【问题标题】:cloud formation template using If condition provision two GSI NonKeyAttributes in dynamodb provision云形成模板在 dynamodb 提供中使用 If 条件提供两个 GSI NonKeyAttributes
【发布时间】:2021-06-06 23:03:36
【问题描述】:

我想使用 if 条件根据参数类型为 dynamodb GSI Non keyattributes 提供两个值。以下是我尝试过但没有奏效的方法。我想根据if条件添加两个属性(att1,att2)

Parameters:  
Apptype:  
string  
Conditions:  
  CIsFinanacial:  
    !Equals [ !Ref Apptype, 'financial' ]

Projection:   
 NonKeyAttributes:   
    !If CIsFinanacial [!Join [","["att1", "att2"], !Ref AWS::Novalue]

上述 if 条件结果为字符串 (att1,att2) 但我希望它们作为字符串列表提供。现在作为一种解决方法,我写了两个条件和两个 if 条件。但是有没有办法在一个 if 条件下提供它们。

对不起,写得不好。

【问题讨论】:

    标签: amazon-web-services amazon-dynamodb amazon-cloudformation


    【解决方案1】:

    我认为下面的表格应该可以工作(你在 NoValue 中也有拼写错误):

    Projection:   
     NonKeyAttributes:   
        !If CIsFinanacial [["att1", "att2"], !Ref AWS::NoValue]
    

    如果不是,那么你可以更明确:

    Projection:   
     NonKeyAttributes:   
        !If 
          - CIsFinanacial 
          - - "att1"
            - "att2"
          - !Ref AWS::NoValue
    

    【讨论】:

    • 我在上面使用时遇到了以下错误。属性 NonKeyAttributes 的值必须是字符串列表类型
    猜你喜欢
    • 2015-02-15
    • 2013-08-07
    • 2017-01-31
    • 1970-01-01
    • 2022-08-11
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多