我有有效的Yaml文件,正在运行Jenkins管道时尝试解析,但看到错误,
init引发异常:无法为!Or构造一个Java对象。 exception =无效的标记:!或在“字符串”的第4行第23列中的15:47:45: 15:47:45 CreateDevResources :!或[!等于[!Ref EnvName,dev ...
作为参考,常规代码类似于
def fileContents = readFile "appTemplate.yaml"
Yaml parser = new Yaml()
List read = parser.load(fileContents)
Yaml文件的内容:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Conditions:
CreateDevResources: !Or [!Equals [ !Ref EnvName, dev ],!Equals [ !Ref EnvName, dev2 ]]
Resources:
MyAuthApi5xxErrorAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled : true
AlarmActions : [ !Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${EnvName}Alerter" ]
OKActions : [ !Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${EnvName}Alerter" ]
AlarmDescription : 'Alerts on API Gateway GetBillingApi 5xx errors'
AlarmName : !Sub ${AWS::StackName}Api5xxError
ComparisonOperator : GreaterThanThreshold
Dimensions :
-
Name: ApiName
Value: !Ref "AWS::StackName"
-
Name: Stage
Value: Prod
EvaluationPeriods : 1
MetricName : 5XXError
Namespace : "AWS/ApiGateway"
Period : 60
Statistic : Average
Threshold : 0 # start with 0 tolerance for error by default
Unit : Count