Class: AWS::IAM::Policy

Inherits:
Core::Policy show all
Defined in:
lib/aws/iam/policy.rb

Overview

Represents an access policy for AWS operations and resources. For example:

policy = Policy.new do |policy|
  policy.allow(:actions => ['s3:PutObject'],
               :resources => "arn:aws:s3:::mybucket/mykey/*",
               :principals => :any
  ).where(:acl).is("public-read")
end

policy.to_json               # => '{ "Version":"2008-10-17", ...'

Defined Under Namespace

Classes: Statement

Instance Attribute Summary

Attributes inherited from Core::Policy

#id, #statements, #version

Instance Method Summary collapse

Methods inherited from Core::Policy

#==, #allow, #deny, from_json, #initialize, #to_json

Constructor Details

This class inherits a constructor from AWS::Core::Policy

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
28
# File 'lib/aws/iam/policy.rb', line 20

def to_h
  hash = super
  hash.delete('Id')
  hash['Statement'].each do |statement|
    statement.delete('Sid')
    statement.delete('Principal')
  end
  hash
end