class Cumulus::IAM::RoleConfig
Public: Represents a config file for a role. Will lazily load its static and template policies as needed.
Attributes
policy_document[RW]
Public Class Methods
new(name = nil, json = nil)
click to toggle source
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"
Calls superclass method
Cumulus::IAM::ResourceWithPolicy::new
# File lib/iam/models/RoleConfig.rb, line 19 def initialize(name = nil, json = nil) super(name, json) @policy_document = Loader.policy_document(json["policy-document"]) unless json.nil? @type = "role" end
Public Instance Methods
diff(aws_resource)
click to toggle source
override diff to check for changes in policy documents
Calls superclass method
Cumulus::IAM::ResourceWithPolicy#diff
# File lib/iam/models/RoleConfig.rb, line 26 def diff(aws_resource) differences = super(aws_resource) aws_policy = JSON.parse(URI.unescape(aws_resource.assume_role_policy_document)).to_s if one_line_policy_document != aws_policy differences << IamDiff.new(IamChange::POLICY_DOC, aws_resource, self) end differences end
hash()
click to toggle source
Calls superclass method
Cumulus::IAM::ResourceWithPolicy#hash
# File lib/iam/models/RoleConfig.rb, line 38 def hash h = super() h["policy-document"] = @policy_document h end
one_line_policy_document()
click to toggle source
Internal: Get the policy document as a one line string for easier comparison
Returns the policy on one line
# File lib/iam/models/RoleConfig.rb, line 47 def one_line_policy_document JSON.parse(@policy_document).to_s end