aws-cloudformation / cloudformation-guard

Guard offers a policy-as-code domain-specific language (DSL) to write rules and validate JSON- and YAML-formatted data such as CloudFormation Templates, K8s configurations, and Terraform JSON plans/configurations against those rules. Take this survey to provide feedback about cfn-guard: https://amazonmr.au1.qualtrics.com/jfe/form/SV_bpyzpfoYGGuuUl0
Apache License 2.0
1.3k stars 180 forks source link

added examples for "Parameter" rules #541

Open pmagyar opened 4 months ago

pmagyar commented 4 months ago

Description of changes:

Hello, i have noticed, that there are no examples, how to check the existence of Parameters and there configuration. It is usefull if you have multiple templates and you want to have in every template the same parameters. (e.g. tagging or name schema)

Hope that will help someone.

Best regards,

Patrick

Test output:

python3-virtualenv ~/git_other/cloudformation-guard/guard-examples/parameter-schemas on  parameter_schema ✓ ❯ cfn-guard test -r check-default-parameters.guard -t check-default-parameters-tests.yaml
Test Case #1
  PASS Rules:
    assert_default_parameter_configuration: Expected = SKIP
    assert_default_parameters_exists: Expected = SKIP
    assert_ConstraintDescription: Expected = SKIP

Test Case #2
  PASS Rules:
    assert_ConstraintDescription: Expected = SKIP
    assert_default_parameters_exists: Expected = PASS
    assert_default_parameter_configuration: Expected = FAIL

Test Case #3
  PASS Rules:
    assert_default_parameters_exists: Expected = FAIL
    assert_default_parameter_configuration: Expected = SKIP
    assert_ConstraintDescription: Expected = SKIP

Test Case #4
  PASS Rules:
    assert_ConstraintDescription: Expected = PASS
    assert_default_parameters_exists: Expected = PASS
    assert_default_parameter_configuration: Expected = PASS

Test Case #5
  PASS Rules:
    assert_default_parameters_exists: Expected = PASS
    assert_default_parameter_configuration: Expected = FAIL
    assert_ConstraintDescription: Expected = FAIL

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

pmagyar commented 1 month ago

Hey,

i have pushed fixes for my typos. Please review/approve again :) Thanks.

Best regards,

Patrick