Class: BuildCloud::IAMManagedPolicy
- Inherits:
-
Object
- Object
- BuildCloud::IAMManagedPolicy
- Includes:
- Component
- Defined in:
- lib/build-cloud/iammanagedpolicy.rb
Overview
IAM Managed Policy is not updated once created, because fog doesn’t support policy versioning right now
Constant Summary collapse
- @@objects =
[]
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ IAMManagedPolicy
constructor
A new instance of IAMManagedPolicy.
-
#read ⇒ Object
(also: #fog_object)
Fog only partly implements collection behaviour for managed policies Work around this using each() - and not, for example, select().
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ IAMManagedPolicy
Returns a new instance of IAMManagedPolicy.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/build-cloud/iammanagedpolicy.rb', line 12 def initialize ( fog_interfaces, log, = {} ) @iam = fog_interfaces[:iam] @log = log @options = @log.debug( .inspect ) (:name, :policy_document) end |
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/build-cloud/iammanagedpolicy.rb', line 25 def create unless exists? @log.info( "Creating new IAM policy #{@options[:name]}" ) policy = @iam.create_policy(@options[:name],JSON.parse(@options[:policy_document]), @options[:policy_path], @options[:policy_description]) @log.debug( policy.inspect ) else policy = fog_object end end |
#delete ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/build-cloud/iammanagedpolicy.rb', line 51 def delete return unless exists? @log.info( "Deleting IAM managed policy #{@options[:name]}" ) @fog.delete_policy(fog_object['Arn']) end |
#read ⇒ Object Also known as: fog_object
Fog only partly implements collection behaviour for managed policies Work around this using each() - and not, for example, select()
43 44 45 46 47 |
# File 'lib/build-cloud/iammanagedpolicy.rb', line 43 def read @iam.managed_policies.each do |item| return item if item.name == @options[:name] end end |