{
  "apiVersion": "json.kyverno.io/v1alpha1",
  "kind": "ValidatingPolicy",
  "metadata": {
    "name": "require-encryption-by-default",
    "annotations": {
      "nova.cloudinit.dev/severity": "high",
      "title.policy.kyverno.io": "S3 buckets and EBS volumes carry encryption config"
    }
  },
  "spec": {
    "rules": [
      {
        "name": "s3-encryption",
        "identifier": "id",
        "assert": {
          "all": [
            {
              "check": {
                "~.resources": {
                  "(type == 'aws:s3:bucket' && !(contains(keys(inputs), 'bucket_encryption') || contains(keys(inputs), 'kms_key_id')))": false
                }
              }
            }
          ]
        }
      },
      {
        "name": "ebs-encryption",
        "identifier": "id",
        "assert": {
          "all": [
            {
              "check": {
                "~.resources": {
                  "(type == 'aws:ebs:volume' && !(contains(keys(inputs), 'encrypted') || contains(keys(inputs), 'kms_key_id')))": false
                }
              }
            }
          ]
        }
      }
    ]
  }
}