Module: AWSCDK::IPolicyValidationPlugin

Included in:
CloudFormationValidatePlugin
Defined in:
i_policy_validation_plugin.rb

Overview

Represents a validation plugin that will be executed during synthesis.

Examples:

class MyPlugin
  include AWSCDK::IPolicyValidationPlugin
  attr_reader :name

  def validate(context)
    # First read the templates using context.templatePaths...

    # ...then perform the validation, and then compose and return the report.
    # Using hard-coded values here for better clarity:
    return {
        success: false,
        violations: [
            {
                rule_name: "CKV_AWS_117",
                description: "Ensure that AWS Lambda function is configured inside a VPC",
                fix: "https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1",
                violating_resources: [
                    {
                        resource_logical_id: "MyFunction3BAA72D1",
                        template_path: "/home/johndoe/myapp/cdk.out/MyService.template.json",
                        locations: ["Properties/VpcConfig"],
                    },
                ],
            },
        ],
    }
  end
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



74
75
76
77
78
79
80
81
# File 'i_policy_validation_plugin.rb', line 74

def self.jsii_overridable_methods
  {
    :name => { kind: :property, name: "name", is_optional: false },
    :rule_ids => { kind: :property, name: "ruleIds", is_optional: true },
    :version => { kind: :property, name: "version", is_optional: true },
    :validate => { kind: :method, name: "validate", is_optional: false },
  }
end

Instance Method Details

#nameString

The name of the plugin that will be displayed in the validation report.

Returns:

  • (String)


40
41
42
# File 'i_policy_validation_plugin.rb', line 40

def name()
  jsii_get_property("name")
end

#rule_idsArray<String>?

Note:

Default: - No rule is reported

The list of rule IDs that the plugin will evaluate.

Used for analytics purposes.

Returns:

  • (Array<String>, nil)


51
52
53
# File 'i_policy_validation_plugin.rb', line 51

def rule_ids()
  jsii_get_property("ruleIds")
end

#validate(context) ⇒ AWSCDK::PolicyValidationPluginReport

The method that will be called by the CDK framework to perform validations.

This is where the plugin will evaluate the CloudFormation templates for compliance and report and violations



69
70
71
72
# File 'i_policy_validation_plugin.rb', line 69

def validate(context)
  Jsii::Type.check_type(context, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JUG9saWN5VmFsaWRhdGlvbkNvbnRleHQifQ==")), "context")
  jsii_call_method("validate", [context])
end

#versionString?

The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.

Returns:

  • (String, nil)


58
59
60
# File 'i_policy_validation_plugin.rb', line 58

def version()
  jsii_get_property("version")
end