class DrawCloud::IAMPolicy

Attributes

document[RW]
document=[RW]
groups[RW]
name[RW]
policy_document[RW]
statements[RW]
users[RW]

Public Class Methods

new(name, options={}, &block) click to toggle source
Calls superclass method DrawCloud::Base::new
# File lib/draw_cloud/iam_policy.rb, line 25
def initialize(name, options={}, &block)
  @name = name
  @groups = []
  @users = []
  @statements = []
  super(options, &block)
end

Public Instance Methods

allow(statement_properties={}) click to toggle source
# File lib/draw_cloud/iam_policy.rb, line 37
def allow(statement_properties={})
  @statements << resourcify_statement_property(statement_properties.merge(:effect => "Allow"))
end
deny(statement_properties={}) click to toggle source
# File lib/draw_cloud/iam_policy.rb, line 41
def deny(statement_properties={})
  @statements << resourcify_statement_property(statement_properties.merge(:effect => "Deny"))
end
iam_policy() click to toggle source
# File lib/draw_cloud/iam_policy.rb, line 33
def iam_policy
  self
end
load_into_config(config) click to toggle source
Calls superclass method DrawCloud::Base#load_into_config
# File lib/draw_cloud/iam_policy.rb, line 49
def load_into_config(config)
  config.cf_add_resource resource_name, self
  super(config)
end
resourcify_statement_property(hash) click to toggle source
# File lib/draw_cloud/iam_policy.rb, line 45
def resourcify_statement_property(hash)
  hash.each_with_object({}) {|(k,v),x| x[DrawCloud.resource_style(k)] = v }
end
to_h() click to toggle source
# File lib/draw_cloud/iam_policy.rb, line 54
def to_h
  h = {
    "Type" => "AWS::IAM::Policy",
    "Properties" => {
      "PolicyName" => resource_name,
      "PolicyDocument" => {
        "Statement" => @statements.collect do |s|
          DrawCloud.ref(s)
        end
      }
    }
  }
  h["Properties"]["Groups"] = groups.collect {|g| DrawCloud.ref(g)} if (groups && !groups.empty?)
  h["Properties"]["Users"] = users.collect {|u| DrawCloud.ref(u)} if (users && !users.empty?)
  add_standard_properties(h)
end