Class: AWSCDK::IAM::PolicyDocument

Inherits:
Jsii::Object
  • Object
show all
Includes:
AWSCDK::IResolvable
Defined in:
iam/policy_document.rb

Overview

A PolicyDocument is a collection of statements.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = nil) ⇒ PolicyDocument

Returns a new instance of PolicyDocument.

Parameters:



10
11
12
13
14
# File 'iam/policy_document.rb', line 10

def initialize(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::IAM::PolicyDocumentProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeURvY3VtZW50UHJvcHMifQ==")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(props)
end

Class Method Details

.from_json(obj) ⇒ AWSCDK::IAM::PolicyDocument

Creates a new PolicyDocument based on the object provided.

This will accept an object created from the .toJSON() call

Parameters:

  • obj (Object)

    the PolicyDocument in object form.

Returns:

  • (AWSCDK::IAM::PolicyDocument)


37
38
39
40
# File 'iam/policy_document.rb', line 37

def self.from_json(obj)
  Jsii::Type.check_type(obj, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "obj")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_iam.PolicyDocument", "fromJson", [obj])
end

.jsii_overridable_methodsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'iam/policy_document.rb', line 16

def self.jsii_overridable_methods
  {
    :creation_stack => { kind: :property, name: "creationStack", is_optional: false },
    :is_empty => { kind: :property, name: "isEmpty", is_optional: false },
    :statement_count => { kind: :property, name: "statementCount", is_optional: false },
    :add_statements => { kind: :method, name: "addStatements", is_optional: false },
    :resolve => { kind: :method, name: "resolve", is_optional: false },
    :to_json => { kind: :method, name: "toJSON", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :validate_for_any_policy => { kind: :method, name: "validateForAnyPolicy", is_optional: false },
    :validate_for_identity_policy => { kind: :method, name: "validateForIdentityPolicy", is_optional: false },
    :validate_for_resource_policy => { kind: :method, name: "validateForResourcePolicy", is_optional: false },
  }
end

Instance Method Details

#add_statements(*statement) ⇒ void

This method returns an undefined value.

Adds a statement to the policy document.

Parameters:



72
73
74
75
76
77
# File 'iam/policy_document.rb', line 72

def add_statements(*statement)
  statement.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement[#{index}]")
  end
  jsii_call_method("addStatements", [*statement])
end

#creation_stackArray<String>

The creation stack of this resolvable which will be appended to errors thrown during resolution.

This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.

Returns:

  • (Array<String>)


48
49
50
# File 'iam/policy_document.rb', line 48

def creation_stack()
  jsii_get_property("creationStack")
end

#is_emptyBoolean

Whether the policy document contains any statements.

Returns:

  • (Boolean)


55
56
57
# File 'iam/policy_document.rb', line 55

def is_empty()
  jsii_get_property("isEmpty")
end

#resolve(context) ⇒ Object

Produce the Token's value at resolution time.

Parameters:

Returns:

  • (Object)


83
84
85
86
# File 'iam/policy_document.rb', line 83

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

#statement_countNumeric

The number of statements already added to this policy.

Can be used, for example, to generate unique "sid"s within the policy.

Returns:

  • (Numeric)


64
65
66
# File 'iam/policy_document.rb', line 64

def statement_count()
  jsii_get_property("statementCount")
end

#to_jsonObject

JSON-ify the document.

Used when JSON.stringify() is called

Returns:

  • (Object)


93
94
95
# File 'iam/policy_document.rb', line 93

def to_json()
  jsii_call_method("toJSON", [])
end

#to_stringString

Encode the policy document as a string.

Returns:

  • (String)


100
101
102
# File 'iam/policy_document.rb', line 100

def to_string()
  jsii_call_method("toString", [])
end

#validate_for_any_policyArray<String>

Validate that all policy statements in the policy document satisfies the requirements for any policy.

Returns:

  • (Array<String>)

    An array of validation error messages, or an empty array if the document is valid.

See Also:



108
109
110
# File 'iam/policy_document.rb', line 108

def validate_for_any_policy()
  jsii_call_method("validateForAnyPolicy", [])
end

#validate_for_identity_policyArray<String>

Validate that all policy statements in the policy document satisfies the requirements for an identity-based policy.

Returns:

  • (Array<String>)

    An array of validation error messages, or an empty array if the document is valid.

See Also:



116
117
118
# File 'iam/policy_document.rb', line 116

def validate_for_identity_policy()
  jsii_call_method("validateForIdentityPolicy", [])
end

#validate_for_resource_policyArray<String>

Validate that all policy statements in the policy document satisfies the requirements for a resource-based policy.

Returns:

  • (Array<String>)

    An array of validation error messages, or an empty array if the document is valid.

See Also:



124
125
126
# File 'iam/policy_document.rb', line 124

def validate_for_resource_policy()
  jsii_call_method("validateForResourcePolicy", [])
end