I am getting "Template contains errors.: [/Resources/CloudTrail/Type/EventSelectors] 'null' values are not allowed in templates" error when I am trying to validate my cloudformation template.
"Conditions":
"S3Enabled":
"Fn::Equals":
- "IsS3Enabled"
- "true"
"Parameters":
"IsS3Enabled":
"AllowedValues":
- "true"
- "false"
"Default": "true"
"Description": "whether you want cloudtrail enabled for S3"
"Type": "String"
"LambdaArns":
"Default": "arn:aws:lambda"
"Description": "The lambda arns of cloudtrail event selectors"
"Type": "CommaDelimitedList"
"S3Arns":
"Default": "'arn:aws:s3:::'"
"Description": "The S3 arns of cloudtrail event selectors"
"Type": "CommaDelimitedList"
"Resources":
"CloudTrail":
"DependsOn":
- "CloudTrailLogBucketPolicy"
"Properties":
"EnableLogFileValidation": "true"
"EventSelectors":
"DataResources": {"Fn::If" : ["S3Enabled", { "Type": "AWS::S3::Object", "Values": !Ref "S3Arns"}, {"Type": "AWS::Lambda::Function", "Values": !Ref "LambdaArns"}]}
"IncludeGlobalServiceEvents": "true"
"IsLogging": "true"
"IsMultiRegionTrail": "true"
"S3BucketName":
"Ref": "CloudTrailLogBucket"
"S3KeyPrefix": "sample"
"TrailName": "sample"
"Type": "AWS::CloudTrail::Trail"
Resources that I am using
- CloudTrail CloudFormation : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-trail.html
- Fn::If documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-if
I have gone through similar questions, both of them leads to indentation, but cannot find a fault with my template.