I have created a yaml template file. I want to tag a lambda function based on a condition as given in the documentation https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
Following is my yaml-
AWSTemplateFormatVersion: '2012-10-10'
Description: "Cloud formation template"
Parameters:
tagName:
Type: String
Description: "tag name for the resource"
Default: test
Conditions:
isConditionalTag:
- Fn::Equals:
- Ref: tagName
- "test"
Resources:
TestambdaFunction:
Properties:
Code:
S3Bucket: "abc-test"
S3Key: xyz-RELEASE.jar
Description: Test Lambda function
Environment:
Variables:
DATA_TYPE: "test-data"
FunctionName: TestFunction
Handler: com.test.testLambda::handleRequest
MemorySize: 200
Role: "arn:aws:iam::user:role/general"
Runtime: java8
Timeout: 300
Tags:
- Key: "component"
Value:
Fn::If:
- isConditionalTag
- Ref: tagName
- "newValue"
Type: AWS::Lambda::Function
There are no formatting errors while runnning the template using boto gives validation error as
boto.exception.BotoServerError: BotoServerError: 400 Bad Request {"Error":{"Code":"ValidationError","Message":"Template format error: Conditions can only be boolean operations on parameters and other conditions","Type":"Sender"},"RequestId":"30250a23-4a66-11e8-a3bd-a14cac12563"}