Class: Ec2SecurityCzar::Base
- Inherits:
-
Object
- Object
- Ec2SecurityCzar::Base
- Defined in:
- lib/ec2-security-czar/base.rb
Instance Attribute Summary collapse
-
#ec2 ⇒ Object
Returns the value of attribute ec2.
Instance Method Summary collapse
-
#initialize(environment = nil, args = {}) ⇒ Base
constructor
A new instance of Base.
- #load_config(region) ⇒ Object
- #update_security_groups ⇒ Object
Constructor Details
#initialize(environment = nil, args = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ec2-security-czar/base.rb', line 13 def initialize(environment=nil, args={}) raise MissingConfig.new("Missing aws_keys.yml config file") unless File.exists?(config_filename) @environment = environment load_config(args[:region]) AWS.config(access_key_id: @config[:access_key], secret_access_key: @config[:secret_key], region: @config[:region]) if @config[:mfa_serial_number] @ec2 = mfa_auth(args[:token]) else @ec2 = AWS.ec2 end end |
Instance Attribute Details
#ec2 ⇒ Object
Returns the value of attribute ec2.
11 12 13 |
# File 'lib/ec2-security-czar/base.rb', line 11 def ec2 @ec2 end |
Instance Method Details
#load_config(region) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ec2-security-czar/base.rb', line 29 def load_config(region) return @config if @config @config = AwsConfig[YAML.load_file(config_filename)] @config = @config[@environment] if @environment @config[:region] = region || 'us-east-1' @config end |
#update_security_groups ⇒ Object
25 26 27 |
# File 'lib/ec2-security-czar/base.rb', line 25 def update_security_groups SecurityGroup.update_security_groups(ec2, @environment, @config[:region]) end |