Zha*_* Yi 4 amazon-web-services aws-cloudformation
我!If在 cloudformation 模板中使用条件。下面的代码具有在项目中ShouldAddWebHook添加或删除的条件。当我运行部署命令时,我收到此错误。为什么它抱怨条件?TriggersAWS::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)
Run Code Online (Sandbox Code Playgroud)
下面是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"
Run Code Online (Sandbox Code Playgroud)
Your !If can't be "hanging" like this. It should be associated with some property. You can try the following:
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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
284 次 |
| 最近记录: |