- I use conditional resource creation for my lambda function.
- When I try to build the template I get presented with the error
InvalidTemplateException Every Condition member must be a string.. The CLI does not provide more details as to where something is wrong.
- As my condition is a string, I'm not sure what is wrong.
Code:
Parameters:
LocalExecution:
Type: String
Default: "false"
Conditions:
IsLocalExecution: !Equals [ !Ref LocalExecution, 'true' ]
Resources:
ProductionDeploy:
Type: AWS::Serverless::Function
Condition: !Not [ IsLocalExecution ]
Properties:
...
LocalExecution:
Type: AWS::Serverless::Function
Condition: IsLocalExecution
Properties:
...
Problem
This is the problem:
Condition: !Not [ IsLocalExecution ]Solution
Create a new condition
Use that condition instead:
Notes
This was a misconception.
!Notwill turn the condition into a boolean value. It's not a string anymore.