I am using !If condition in cloudformation template. Below code has a condition ShouldAddWebHook to add or remove Triggers in AWS::CodeBuild::Project project. When I run deploy command I got this error. Why it complains about !If condition?
while scanning a simple key
in "<unicode string>", line 93, column 7:
!If
^ (line: 93)
could not find expected ':'
in "<unicode string>", line 94, column 9:
- ShouldAddWebHook
^ (line: 94)
Below is cloudformation template:
Conditions:
ShouldAddWebHook: !Equals [ !Ref ShouldAddWebHook, "true" ]
Resources:
CodeBuildProjectDeployment:
Type: AWS::CodeBuild::Project
Properties:
Name: test
Artifacts:
Type: NO_ARTIFACTS
Environment:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/amazonlinux2-x86_64-standard:2.0
Source:
Type: BITBUCKET
Location: !Ref BitbucketCloneUrl
GitCloneDepth: 26
BuildSpec: buildspec.yml
TimeoutInMinutes: 10
BadgeEnabled: true
!If
- ShouldAddWebHook
- Triggers:
Webhook: true
FilterGroups:
- - Pattern: PUSH
Type: EVENT
- !Ref "AWS::NoValue"