Class: AWSCDK::PolicyViolation

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
policy_violation.rb

Overview

Violation produced by the validation plugin.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, rule_name:, violating_resources:, fix: nil, rule_metadata: nil, severity: nil) ⇒ PolicyViolation

Returns a new instance of PolicyViolation.

Parameters:

  • description (String)

    The description of the violation.

  • rule_name (String)

    The name of the rule.

  • violating_resources (Array<AWSCDK::PolicyViolatingResource>)

    The resources violating this rule.

  • fix (String, nil) (defaults to: nil)

    How to fix the violation.

  • rule_metadata (Hash{String => String}, nil) (defaults to: nil)

    Additional metadata to include with the rule results.

  • severity (String, nil) (defaults to: nil)

    The severity of the violation, only used for reporting purposes.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'policy_violation.rb', line 13

def initialize(description:, rule_name:, violating_resources:, fix: nil, rule_metadata: nil, severity: nil)
  @description = description
  Jsii::Type.check_type(@description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description")
  @rule_name = rule_name
  Jsii::Type.check_type(@rule_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "ruleName")
  @violating_resources = violating_resources.is_a?(Array) ? violating_resources.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::PolicyViolatingResource.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : violating_resources
  Jsii::Type.check_type(@violating_resources, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLlBvbGljeVZpb2xhdGluZ1Jlc291cmNlIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "violatingResources")
  @fix = fix
  Jsii::Type.check_type(@fix, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fix") unless @fix.nil?
  @rule_metadata = 
  Jsii::Type.check_type(@rule_metadata, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "ruleMetadata") unless @rule_metadata.nil?
  @severity = severity
  Jsii::Type.check_type(@severity, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "severity") unless @severity.nil?
end

Instance Attribute Details

#descriptionString (readonly)

The description of the violation.

Returns:

  • (String)


31
32
33
# File 'policy_violation.rb', line 31

def description
  @description
end

#fixString? (readonly)

Note:

Default: - no fix is provided

How to fix the violation.

Returns:

  • (String, nil)


44
45
46
# File 'policy_violation.rb', line 44

def fix
  @fix
end

#rule_metadataHash{String => String}? (readonly)

Note:

Default: - no rule metadata

Additional metadata to include with the rule results.

This can be used to provide additional information that is plugin specific. The data provided here will be rendered as is.

Returns:

  • (Hash{String => String}, nil)


52
53
54
# File 'policy_violation.rb', line 52

def 
  @rule_metadata
end

#rule_nameString (readonly)

The name of the rule.

Returns:

  • (String)


35
36
37
# File 'policy_violation.rb', line 35

def rule_name
  @rule_name
end

#severityString? (readonly)

Note:

Default: - no severity

The severity of the violation, only used for reporting purposes.

This is useful for helping the user discriminate between warnings, errors, information, etc.

Returns:

  • (String, nil)


60
61
62
# File 'policy_violation.rb', line 60

def severity
  @severity
end

#violating_resourcesArray<AWSCDK::PolicyViolatingResource> (readonly)

The resources violating this rule.



39
40
41
# File 'policy_violation.rb', line 39

def violating_resources
  @violating_resources
end

Class Method Details

.jsii_propertiesObject



62
63
64
65
66
67
68
69
70
71
# File 'policy_violation.rb', line 62

def self.jsii_properties
  {
    :description => "description",
    :rule_name => "ruleName",
    :violating_resources => "violatingResources",
    :fix => "fix",
    :rule_metadata => "ruleMetadata",
    :severity => "severity",
  }
end

Instance Method Details

#to_jsiiObject



73
74
75
76
77
78
79
80
81
82
83
84
# File 'policy_violation.rb', line 73

def to_jsii
  result = {}
  result.merge!({
    "description" => @description,
    "ruleName" => @rule_name,
    "violatingResources" => @violating_resources,
    "fix" => @fix,
    "ruleMetadata" => @rule_metadata,
    "severity" => @severity,
  })
  result.compact
end