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.