Module: OpsWorks::CLI::Subcommands::Allow

Included in:
Agent
Defined in:
lib/opsworks/cli/subcommands/allow.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object

rubocop:disable MethodLength rubocop:disable CyclomaticComplexity



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/opsworks/cli/subcommands/allow.rb', line 9

def self.included(thor)
  thor.class_eval do
    desc 'allow USER [--stack STACK]', 'Allow an IAM user on a stack'
    option :stack, type: :array
    option :ssh, type: :boolean, default: true
    option :sudo, type: :boolean, default: true
    def allow(user)
      fetch_keychain_credentials unless env_credentials?
      stacks = parse_stacks(options.merge(active: true))
      stacks.each do |stack|
        permission = stack.find_permission_by_user(user)
        next unless permission
        say "Updating permissions on #{stack.name}..."
        permission.update(ssh: options[:ssh], sudo: options[:sudo])
      end
    end
  end
end