Class: Opsicle::Permit
- Inherits:
-
Object
- Object
- Opsicle::Permit
- Defined in:
- lib/opsicle/commands/permit.rb
Instance Method Summary collapse
- #all_stack_ids ⇒ Object
- #current_stack_id ⇒ Object
- #execute(options = {}) ⇒ Object
- #iam_user_arns(user_names) ⇒ Object
-
#initialize(environment) ⇒ Permit
constructor
A new instance of Permit.
Constructor Details
Instance Method Details
#all_stack_ids ⇒ Object
16 17 18 |
# File 'lib/opsicle/commands/permit.rb', line 16 def all_stack_ids @client.api_call(:describe_stacks)[:stacks].map{ |stack| stack[:stack_id] } end |
#current_stack_id ⇒ Object
20 21 22 |
# File 'lib/opsicle/commands/permit.rb', line 20 def current_stack_id @client.config.opsworks_config[:stack_id] end |
#execute(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/opsicle/commands/permit.rb', line 7 def execute(={}) stack_ids = [:all_stacks] ? all_stack_ids : [current_stack_id] stack_ids.each do |stack_id| iam_user_arns([:user]).each do |arn| (arn, stack_id) end end end |
#iam_user_arns(user_names) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/opsicle/commands/permit.rb', line 24 def iam_user_arns(user_names) if user_names && !user_names.empty? user_names.map do |user_name| profile = profiles.detect{ |profile| profile[:name] == user_name || profile[:ssh_username] == user_name} raise ArgumentError, "User #{user_name} not found" unless profile profile[:iam_user_arn] end else [UserProfile.new(@client).arn] end end |