我!If
在cloudformation模板中使用条件。下面的代码具有在项目中ShouldAddWebHook
添加或删除的条件。当我运行deploy命令时,出现此错误。为什么抱怨状况?Triggers
AWS::CodeBuild::Project
!If
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)
以下是cloudformation模板:
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"
您!If
不能像这样“挂”。它应与某些属性关联。您可以尝试以下操作:
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
Triggers:
!If
- ShouldAddWebHook
- Webhook: true
FilterGroups:
- - Pattern: PUSH
Type: EVENT
- !Ref "AWS::NoValue"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句