最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

yaml - Is there a way to dynamically reference a condition in cloudformation - Stack Overflow

programmeradmin0浏览0评论

I am trying to dynamically create the keys of a DynamoDB from a mapping. I have a condition that if the mapping of a table has a PartitionKey value, then it returns True. I want to reference the specific condition for each table to optionally create a partition key. However when Using the code below, and similar versions, I get the error Transform AWS::LanguageExtensions failed with: Fn::If layout is incorrect

Is there a way to make this work in cloudformation?

Conditions:
  'Fn::ForEach::CheckPartitionKeyTrue':
    - TableName
    - !Ref DynamodbTableNames
    - '${TableName}HasPartitionKey': !Not
        - !Equals
            - !FindInMap
              - DynamodbMap
              - !Ref TableName
              - PartitionKey
              - DefaultValue: ''
            - ''

Resources:
  'Fn::ForEach::DynamodbTable':
    - TableName
    - !Ref DynamodbTableNames
        Properties:
          AttributeDefinitions:
            - AttributeName: PrimaryKey
              AttributeType: S
            - AttributeName: !If
                - !Sub '${TableName}HasPartitionKey'
                - PartitionKey
                - !Ref "AWS::NoValue"

I've use the cloudformation linter, and no errors appear with the code above, but it seems like you might be unable to use functions to reference the condition with a function but am not certain.

发布评论

评论列表(0)

  1. 暂无评论