cfn-guard 3.2.0

AWS CloudFormation Guard is an open-source general-purpose policy-as-code evaluation tool. It provides developers with a simple-to-use, yet powerful and expressive domain-specific language (DSL) to define policies and enables developers to validate JSON- or YAML- formatted structured data with those policies.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let template = Resources.*[ Type == 'AWS::New::Service']

rule SOME_RULE when %template !empty {
    let collection = %template.Collection.*

    let res = join(%collection, ",")
    %res == "a,b,c"
}


let buckets = Resources[ Type == 'AWS::S3::Bucket' ]

rule SOME_BUCKET_RULE when %buckets !empty {
    let res = join(%buckets.Type, '-')

    %res == "AWS::S3::Bucket-AWS::S3::Bucket-AWS::S3::Bucket-AWS::S3::Bucket-AWS::S3::Bucket"
}