Class: Cumulus::IAM::RoleConfig
- Inherits:
-
ResourceWithPolicy
- Object
- ResourceWithPolicy
- Cumulus::IAM::RoleConfig
- Defined in:
- lib/iam/models/RoleConfig.rb
Overview
Public: Represents a config file for a role. Will lazily load its static and template policies as needed.
Instance Attribute Summary collapse
-
#policy_document ⇒ Object
Returns the value of attribute policy_document.
Attributes inherited from ResourceWithPolicy
#attached_policies, #inlines, #name, #statics, #type
Instance Method Summary collapse
-
#diff(aws_resource) ⇒ Object
override diff to check for changes in policy documents.
- #hash ⇒ Object
-
#initialize(name = nil, json = nil) ⇒ RoleConfig
constructor
Public: Constructor.
-
#one_line_policy_document ⇒ Object
Internal: Get the policy document as a one line string for easier comparison.
Methods inherited from ResourceWithPolicy
#generated_policy_name, #json, #policy
Constructor Details
#initialize(name = nil, json = nil) ⇒ RoleConfig
Public: Constructor.
name - the name of the role json - the Hash containing the JSON configuration for this RoleConfig, if
nil, this will be an "empty RoleConfig"
20 21 22 23 24 |
# File 'lib/iam/models/RoleConfig.rb', line 20 def initialize(name = nil, json = nil) super(name, json) @policy_document = Loader.policy_document(json["policy-document"]) unless json.nil? @type = "role" end |
Instance Attribute Details
#policy_document ⇒ Object
Returns the value of attribute policy_document.
13 14 15 |
# File 'lib/iam/models/RoleConfig.rb', line 13 def policy_document @policy_document end |
Instance Method Details
#diff(aws_resource) ⇒ Object
override diff to check for changes in policy documents
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/iam/models/RoleConfig.rb', line 27 def diff(aws_resource) differences = super(aws_resource) aws_policy = JSON.parse(URI.unescape(aws_resource.assume_role_policy_document)).to_s if eval(one_line_policy_document).deep_sort != eval(aws_policy).deep_sort differences << IamDiff.new(IamChange::POLICY_DOC, aws_resource, self) end differences end |
#hash ⇒ Object
39 40 41 42 43 |
# File 'lib/iam/models/RoleConfig.rb', line 39 def hash h = super() h["policy-document"] = @policy_document h end |
#one_line_policy_document ⇒ Object
Internal: Get the policy document as a one line string for easier comparison
Returns the policy on one line
48 49 50 |
# File 'lib/iam/models/RoleConfig.rb', line 48 def one_line_policy_document JSON.parse(@policy_document).to_s end |