cucloud 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 44af2a11862546a86d51007367bb60435cd1d1a6
4
- data.tar.gz: 2da4a56dedfbe59e18808bb75d03f9e52cb89dd1
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzQ3Y2ZmNTA0ZGNkMjllZWY2ZDAzNTZhMWU2OTJkMDYxMGQ3Mjg5ZQ==
5
+ data.tar.gz: !binary |-
6
+ ZTk0NDQ1YWViYjc5YTAzZGZhMjc3MTI5ZTg5ZDE3MzgzMWJjMzM1NQ==
5
7
  SHA512:
6
- metadata.gz: 2bc06c3130c24a50da39649842af27957e247d9ed90112007d26eb98554291e9f4271ea133d86a1f3000a431a091643fa7eb2a3ab68af254b33ecf94a9afc8cd
7
- data.tar.gz: 93b0348b3c46ffee49bba413c7cf89c27de3f2c843f116e902833eb864eb07bc74ae53f123b4488522ad48187202d5503cad9e3f6ac83811d66c9583f5987a1a
8
+ metadata.gz: !binary |-
9
+ N2Y2Zjg0YzA2M2YyZWUwNWNkMTAwNjUyZmQ5OTU4N2NjNmZhMDZiODg4NzMz
10
+ M2NlYzIzZGIxMjNmNTcyNDhmOThjMmE1ODc2OWRhNGVhODBkNGNjZDA3Mzdl
11
+ NzAxZDNhNjcwMjUzMTRhMDMxMjlmNTg2Yjc0MTRjMDA0Mzg3MWI=
12
+ data.tar.gz: !binary |-
13
+ ZTg4YjMwNTNlYWRmNDljNThlNTRiZDIzMmIwMjUwNmZlYjkwZDU0MjIzMWVh
14
+ NjVkZjc0YTc1YTgyZTQzMDg3ZTQxNjcyOTlkMTFiNjkwYTM1Y2FkNTZlYWUz
15
+ MDFlZWEwNmY1N2VjZmZkYmM0YzE3OWMyMDMzZjRlMmFkNGZlNzA=
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ LineLength:
2
+ Description: 'Limit lines to 120 characters.'
3
+ Max: 120
4
+ Enabled: true
5
+
6
+ Metrics/MethodLength:
7
+ CountComments: false # count full line comments?
8
+ Max: 100
9
+
10
+ Metrics/AbcSize:
11
+ Max: 50
data/.travis.yml CHANGED
@@ -1,4 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
3
+ - 2.1.2
4
4
  before_install: gem install bundler -v 1.11.2
5
+ script:
6
+ - bundle exec rake spec
7
+ - bundle exec rubocop
8
+ deploy:
9
+ provider: rubygems
10
+ api_key:
11
+ secure: quX8eTwtDAOjeKfT3u70OSlLZcCDFRvlT5Alb/wKhf8lmCZPLeOo+DvoCqoTPE3PglVl8mwmdtEFhFIfbKmZ4Xjl+QqIZy+GAQpp2KLvXYotENZR3NyQGnwmQq3OE8MBLM6+OiteIaKPXy2GlbAQSHbuMSpa9BLnyNiFNoN57YW1b/Ni1sts8qGfNxPzueK6RqXg97Z/TRwDPm/e4Z/R7KVt93w/WdRBU1x/UvBHMN6/A3LqaFoImE8xNyukYSK5XLRn+m43plF2EzeQUPCOgiyvTOk+6LczkdBwP9qV+PNEIT96IXb9+olM/0jlmlLKoZ/d4VaLQNmnlGR0dWRcRvAjHtucXV5/IFyPetKhbrjmhh9t0FwxqG6l9cpo5bJgJh7GeAqdFtP1easM+QxYm9ChxKAuHopIGTyv3vUjBspv8LibAKjlHDofA+mrXFAMsmHEj0QCYIMYXyjDR6fOtTwuqkyPHQe2Kx0sxNA1ygrXURToous97rE0dw1yaBjjo+2vUDcXZa/ViFaJM4in51hNd5JZV6NXaaTUkL6m7bCMb/yxhbo1JJDKJt+Dxq1ISWElDcM1PChXl/mbPm8FHChJNXNNJBXyAXY91XeewTOIn1N5TSTyH9GjmgEDbygW3W0TTbLWgIzdtyVTPafQw/RrDttW0rWkSKnRPthCFDk=
12
+ gem: cucloud
13
+ on:
14
+ tags: true
15
+ repo: CU-CloudCollab/cucloud_ruby
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --readme README.md
2
+ --title 'CUCloud Ruby Library'
3
+ --markup markdown
4
+ 'lib/**/*.rb' - '*.md'
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in cucloud.gemspec
4
4
  gemspec
5
-
6
- gem 'aws-sdk'
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Cucloud
1
+ # Cucloud ![Build Status](https://api.travis-ci.org/CU-CloudCollab/cucloud_ruby.svg)
2
2
 
3
- The cucloud module is intended to provide functionality requiring more customization than could otherwise be simply accomplished with a cloud specific command line interface, e.g. AWS CLI
3
+ The cucloud module is intended to serve as a lightweight wrapper around the AWS SDK that can be used to share common functionality across various AWS utilities and tools that we develop at Cornell. Goals:
4
+
5
+ * Standardize credential management and client instantiation so that all of our utilities use the same approach
6
+ * Encapsulate the work of building json/hash requests and parsing responses, to provide a simple/consistent API through which our utilities interact with AWS
7
+ * Provide methods that fill in "gaps" in the SDK functionality (e.g., make it easier to work across SDK silos; reduce multi-step chained api calls to single method calls)
8
+ * Provide a standard approach to unit testing using rspec and AWS stubs
4
9
 
5
10
  ## Installation
6
11
 
@@ -20,12 +25,59 @@ Or install it yourself as:
20
25
 
21
26
  ## Usage
22
27
 
28
+ Within an app - simply require the cucloud gem as noted above, then include functionality as needed.
29
+
30
+ For example, to use the Auto Scaling Group functionality:
31
+
32
+ ```
33
+ # get the autoscale group utilities
34
+ asg_utils = Cucloud::AsgUtils.new
35
+
36
+ # get an autoscale group by name
37
+ asg = asg_utils.get_asg_by_name('my-autoscale-group')
38
+
39
+ # output the launch configuration name
40
+ puts asg.launch_configuration_name
41
+
42
+ ```
43
+
44
+ Note - the cucloud library assumes that environment credentials are available to the AWS SDK. See https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs for more info.
45
+
46
+ ## Example Utility Implementations
47
+
48
+ Utilities that use this API:
49
+
50
+ * Autoscale AMI Updater: https://github.com/CU-CloudCollab/asg-ami-update
51
+
52
+
23
53
  ## Development
24
54
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+ After checking out the repo, run `bin/setup` to install dependencies.
56
+
57
+ To run styleguide/syntax tests:
58
+ ``` $ bundle exec rubocop ```
59
+
60
+ To run unit tests:
61
+ ``` $ bundle exec rake spec ```
62
+
63
+ To generate documentation:
64
+ ``` bundle exec yard ```
26
65
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+ To install this gem onto your local machine:
67
+ ``` bundle exec rake install ```
68
+
69
+ It's helpful to reference a local copy of the gem while developing (so you can add methods to cucloud and reference them in the utility you are developing) -- see https://rossta.net/blog/how-to-specify-local-ruby-gems-in-your-gemfile.html for a recommended approach.
28
70
 
29
71
  ## Contributing
30
72
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/CU-CloudCollab/cucloud_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/CU-CloudCollab/cucloud_ruby. The library includes functions that have been needed somewhere already - it is in no way complete yet and we love contributions!
74
+
75
+ General guidance for contributions:
76
+
77
+ * cucloud is intended to be an API consumed by other applications - in general, any user input/output/interaction should be pushed to utilities that consume this library.
78
+ * Pull requests should include code and passing rspec unit tests for any new methods.
79
+ * Methods and classes should be documented in the YARD format (http://yardoc.org/).
80
+ * Code should conform to Ruby Community Styleguide and pass rubocop checks using the included rubocop config (https://github.com/bbatsov/ruby-style-guide).
81
+
82
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
83
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "cucloud"
3
+ require 'bundler/setup'
4
+ require 'cucloud'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "cucloud"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/cucloud.gemspec CHANGED
@@ -1,24 +1,35 @@
1
1
  # coding: utf-8
2
+ # rubocop:disable Style/WordArray
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'cucloud/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "cucloud"
8
+ spec.name = 'cucloud'
8
9
  spec.version = Cucloud::VERSION
9
- spec.authors = ["sbower"]
10
- spec.email = ["shawn.bower@gmail.com"]
10
+ spec.authors = ['sbower', 'bharanin', 'sross07']
11
11
 
12
- spec.summary = %q{The cucloud module is intended to provide functionality requiring more customization than could otherwise be simply accomplished with a cloud specific command line interface, e.g. AWS CLI}
13
- spec.description = %q{The cucloud module is intended to provide functionality requiring more customization than could otherwise be simply accomplished with a cloud specific command line interface, e.g. AWS CLI}
14
- spec.homepage = "https://github.com/CU-CloudCollab/cucloud_ruby"
12
+ spec.email = ['shawn.bower@gmail.com', 'bmh67@cornell.edu', 'sr523@cornell.edu']
13
+
14
+ spec.summary = 'The cucloud module is intended to provide functionality requiring more customization than ' \
15
+ 'could otherwise be simply accomplished with a cloud specific command line interface, e.g. ' \
16
+ 'AWS CLI'
17
+ spec.description = 'The cucloud module is intended to provide functionality requiring more customization than ' \
18
+ 'could otherwise be simply accomplished with a cloud specific command line interface, e.g. ' \
19
+ 'AWS CLI'
20
+ spec.homepage = 'https://github.com/CU-CloudCollab/cucloud_ruby'
15
21
 
16
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
23
+ spec.bindir = 'exe'
18
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_dependency 'aws-sdk', '~> 2'
28
+ spec.add_dependency 'uuid', '~> 2.3'
20
29
 
21
- spec.add_development_dependency "bundler", "~> 1.11"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency 'bundler', '~> 1.11'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ spec.add_development_dependency 'rubocop', '~> 0.40.0'
34
+ spec.add_development_dependency 'yard', '~> 0.9.0'
24
35
  end
data/lib/cucloud.rb CHANGED
@@ -1,20 +1,22 @@
1
1
  require 'aws-sdk'
2
2
 
3
+ # Main Cucloud Module namespace and defaults
3
4
  module Cucloud
4
5
  require 'cucloud/version'
5
6
  require 'cucloud/ec2_utils'
7
+ require 'cucloud/asg_utils'
6
8
 
7
- DEFAULT_REGION = 'us-east-1'
9
+ DEFAULT_REGION = 'us-east-1'.freeze
8
10
 
9
- Aws.config = {region: DEFAULT_REGION}
11
+ Aws.config = { region: DEFAULT_REGION }
10
12
 
11
13
  def region
12
14
  @region
13
15
  end
14
-
16
+
15
17
  def region=(region)
16
18
  @region = region
17
- Aws.config = {region: @region}
19
+ Aws.config = { region: @region }
18
20
  end
19
21
 
20
22
  module_function :region, :region=
@@ -0,0 +1,71 @@
1
+ module Cucloud
2
+ # AsgUtils - Utilities for AutoScaling groups
3
+ class AsgUtils
4
+ require 'uuid'
5
+
6
+ # Constructor for AsgUtils class
7
+ # @param asg_client [Aws::AutoScaling::Client] AWS AutoScaling SDK Client
8
+ def initialize(asg_client = Aws::AutoScaling::Client.new)
9
+ ## DI for testing purposes
10
+ @asg = asg_client
11
+ end
12
+
13
+ # Get an autoscale instance by group name
14
+ # @param name [String] A single autoscale group name
15
+ # @return [Aws::AutoScaling::Types::AutoScalingGroup] AWS SDK autoscale group struct
16
+ def get_asg_by_name(name)
17
+ # https://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_auto_scaling_groups-instance_method
18
+ asg_desc = @asg.describe_auto_scaling_groups(auto_scaling_group_names: [name])
19
+
20
+ # nil if not found -> we're accepting one name, so return first result
21
+ asg_desc.auto_scaling_groups[0]
22
+ end
23
+
24
+ # get an instance of the launch configuration for a given autoscaling group
25
+ # @param launch_config_name [String] Name of launch configuration (from ASG)
26
+ # @return [Aws::AutoScaling::Types::LaunchConfiguration] AWS SDK Launch Configuration struct
27
+ def get_launch_configuration_by_name(launch_config_name)
28
+ # https://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_launch_configurations-instance_method
29
+ lc_desc = @asg.describe_launch_configurations(launch_configuration_names: [launch_config_name])
30
+ lc_desc.launch_configurations[0]
31
+ end
32
+
33
+ # Generate a hash that can be submitted when creating a new launch config - replace image with desired AMI
34
+ # @param launch_config [Aws::AutoScaling::Types::LaunchConfiguration] Existing launch configuration
35
+ # @param new_ami_id [String] Id of AMI that should be added to the new configuration
36
+ # @param new_launch_config_name [String] Name of new launch configuration (must be unique in AWS account)
37
+ # @return [Hash] Options hash to be submitted via AWS SDK
38
+ def generate_lc_options_hash_with_ami(launch_config, new_ami_id,
39
+ new_launch_config_name = "cucloud-lc-#{UUID.new.generate}")
40
+
41
+ # make sure we got a valid launch config
42
+ raise 'Not a launch configuration struct' unless launch_config.is_a? Aws::AutoScaling::Types::LaunchConfiguration
43
+
44
+ # convert to hash (required for aws sdk) and update necessary values
45
+ config_hash = launch_config.to_h
46
+ config_hash[:launch_configuration_name] = new_launch_config_name
47
+ config_hash[:image_id] = new_ami_id
48
+
49
+ # request cannot have arn, created_time or keys with empty values
50
+ config_hash.delete_if { |key, value| key == :launch_configuration_arn || key == :created_time || value == '' }
51
+ end
52
+
53
+ # Create new launch configuration in AWS
54
+ # @param options [Hash] Options hash to be passed along in request
55
+ # @return [Seahorse::Client::Response] Empty Seahorse Client Response
56
+ def create_launch_configuration(options)
57
+ # https://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_launch_configuration-instance_method
58
+ @asg.create_launch_configuration(options)
59
+ end
60
+
61
+ # Update autoscale group launch configuration
62
+ # @param asg_name [String] AutoScale group name
63
+ # @param launch_config_name [String] Launch configuration name
64
+ # @return [Seahorse::Client::Response] Empty Seahorse Client Response
65
+ def update_asg_launch_configuration!(asg_name, launch_config_name)
66
+ # https://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#update_auto_scaling_group-instance_method
67
+ @asg.update_auto_scaling_group(auto_scaling_group_name: asg_name,
68
+ launch_configuration_name: launch_config_name)
69
+ end
70
+ end
71
+ end
@@ -1,20 +1,128 @@
1
- class Cucloud::Ec2Utils
2
- MAX_TIMEOUT = 480
3
- SECONDS_IN_A_DAY = 86400
1
+ module Cucloud
2
+ # EC2Utils class - anything ec2 related goes here!
3
+ class Ec2Utils
4
+ MAX_TIMEOUT = 480
5
+ SECONDS_IN_A_DAY = 86_400
6
+ UBUNTU_PATCH_COMMAND = 'apt-get update; apt-get -y upgrade; reboot'.freeze
7
+ AMAZON_PATCH_COMMAND = 'yum update -y; reboot & disown '.freeze
4
8
 
5
- def initialize
6
- @ec2 = Aws::EC2::Client.new
7
- end
9
+ def initialize(ec2_client = Aws::EC2::Client.new)
10
+ ## DI for testing purposes
11
+ @ec2 = ec2_client
12
+ end
8
13
 
9
- def get_instances_by_tag(tag_name, tag_value)
10
- @ec2.describe_instances({
11
- filters: [
12
- {
13
- name: "tag:#{tag_name}",
14
- values: [tag_value],
15
- }
16
- ]
17
- })
18
- end
14
+ def get_instance(instance)
15
+ ## Get instance information for a specific instance
16
+ @ec2.describe_instances(instance_ids: [instance])
17
+ end
18
+
19
+ def stop_instance(instance)
20
+ # Stop ec2 instance for a specific instance number. The function will wait until the instance has entered
21
+ # the stopped state.
22
+ @ec2.stop_instances(instance_ids: [instance])
23
+ end
24
+
25
+ def start_instance(instance)
26
+ # Start ec2 instance for a specific instance number. The function will wait until the instance has entered
27
+ # the running state.
28
+ @ec2.start_instances(instance_ids: [instance])
29
+ end
30
+
31
+ def rename_instance(instance, name)
32
+ # Set the name of the instance that will be displayed in the ec2 console
33
+ end
34
+
35
+ def reboot_instance(instance)
36
+ end
37
+
38
+ def delete_instance(instance)
39
+ ## Terminate ec2 instance for a specific instance number.
40
+ end
41
+
42
+ def associate_eip(instance, allocation_id)
43
+ # Assoications an Elastic IP adress with a specific instance number.
44
+
45
+ # Return: association_id as a string in the form of eipassoc-569cd631. This is the link between between the
46
+ # elastic network interface and the elastic IP address.
47
+ end
48
+
49
+ def create_instance(options)
50
+ ## Create ec2 instance based on parameters provided. The function will pull in default information from ?????.
51
+ ## Options will be hash that will override the default
52
+ ## Default will need to be pulled from ... ??
53
+ end
54
+
55
+ def deregister_image(image)
56
+ # Remove private AMI
57
+ end
19
58
 
59
+ def find_ami(name)
60
+ # Find ami based on a search of Name
61
+ end
62
+
63
+ def get_instances_by_tag(tag_name, tag_value)
64
+ ## Based on tag name and value, return instances
65
+ @ec2.describe_instances(filters: [
66
+ {
67
+ name: "tag:#{tag_name}",
68
+ values: tag_value
69
+ }
70
+ ])
71
+ end
72
+
73
+ def stop_instances_by_tag(tag_name, tag_value)
74
+ get_instances_by_tag(tag_name, tag_value).reservations[0].instances.each do |i|
75
+ @ec2.stop_instances(instance_ids: [i.instance_id])
76
+ end
77
+ end
78
+
79
+ def start_instances_by_tag(tag_name, tag_value)
80
+ get_instances_by_tag(tag_name, tag_value).reservations[0].instances.each do |i|
81
+ @ec2.start_instances(instance_ids: [i.instance_id])
82
+ end
83
+ end
84
+
85
+ def send_patch_command(patch_instances, command)
86
+ ssm = Aws::SSM::Client.new(region: 'us-east-1')
87
+
88
+ ssm.send_command(instance_ids: patch_instances, # required
89
+ document_name: 'AWS-RunShellScript', # required
90
+ timeout_seconds: 600,
91
+ comment: 'Patch It!',
92
+ parameters: {
93
+ 'commands' => [command]
94
+ })
95
+ end
96
+
97
+ # rubocop:disable Metrics/CyclomaticComplexity
98
+ # rubocop:disable Metrics/PerceivedComplexity
99
+ # @todo consider refactoring/breaking out functionality so that complexity metrics pass
100
+ def instances_to_patch_by_tag(tag_name = 'auto_patch', tag_value = ['1'])
101
+ resp = get_instances_by_tag(tag_name, tag_value)
102
+
103
+ ubuntu_patch_instances = []
104
+ amazon_patch_instances = []
105
+ all_instances = []
106
+
107
+ resp.reservations.each do |res|
108
+ res.instances.each do |instance|
109
+ instance.tags.each do |tag|
110
+ next unless tag.key.eql?('os')
111
+ if tag.value.eql?('ubuntu')
112
+ ubuntu_patch_instances.push(instance.instance_id)
113
+ all_instances.push(instance.instance_id)
114
+ elsif tag.value.eql?('ecs') || tag.value.eql?('amazon')
115
+ amazon_patch_instances.push(instance.instance_id)
116
+ all_instances.push(instance.instance_id)
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ send_patch_command(ubuntu_patch_instances, UBUNTU_PATCH_COMMAND) if ubuntu_patch_instances.any?
123
+ send_patch_command(amazon_patch_instances, AMAZON_PATCH_COMMAND) if amazon_patch_instances.any?
124
+
125
+ all_instances
126
+ end
127
+ end
20
128
  end
@@ -0,0 +1,31 @@
1
+ module Cucloud
2
+ # ElbUtils class - methods related to elb
3
+ class ElbUtils
4
+ def initialize(s3 = Aws::S3::Client.new)
5
+ @s3 = s3
6
+ end
7
+
8
+ def enable_logging(elb_name, app_name, policy, _elb = Aws::ElasticLoadBalancing::Client.new)
9
+ ## Added by Scott Ross
10
+ ## Stand alone script found here: https://github.com/CU-CloudCollab/elb-logging/
11
+ ## Manual process: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/enable-access-logs.html
12
+
13
+ bucket_name = "#{elb_name}-logging"
14
+
15
+ @s3.create_bucket(bucket: bucket_name)
16
+ s3.put_bucket_policy(bucket: bucket_name,
17
+ policy: policy.to_json)
18
+
19
+ elb_client.modify_load_balancer_attributes(load_balancer_name: elb_name, # required
20
+ load_balancer_attributes: {
21
+ access_log: {
22
+ enabled: true, # required
23
+ s3_bucket_name: bucket_name,
24
+ emit_interval: 5,
25
+ s3_bucket_prefix: app_name
26
+ }
27
+ })
28
+ s3.list_objects(bucket: bucket_name).contents.length == 1 ? 0 : 1
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,5 @@
1
1
  module Cucloud
2
- VERSION = "0.1.1"
2
+ # Disable mutable constant warning - freezing this oddly breaks bundler
3
+ # rubocop:disable Style/MutableConstant
4
+ VERSION = '0.2.0'
3
5
  end
metadata CHANGED
@@ -1,69 +1,131 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sbower
8
+ - bharanin
9
+ - sross07
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
13
+ date: 2016-07-13 00:00:00.000000000 Z
12
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: aws-sdk
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: '2'
29
+ - !ruby/object:Gem::Dependency
30
+ name: uuid
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '2.3'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '2.3'
13
43
  - !ruby/object:Gem::Dependency
14
44
  name: bundler
15
45
  requirement: !ruby/object:Gem::Requirement
16
46
  requirements:
17
- - - "~>"
47
+ - - ~>
18
48
  - !ruby/object:Gem::Version
19
49
  version: '1.11'
20
50
  type: :development
21
51
  prerelease: false
22
52
  version_requirements: !ruby/object:Gem::Requirement
23
53
  requirements:
24
- - - "~>"
54
+ - - ~>
25
55
  - !ruby/object:Gem::Version
26
56
  version: '1.11'
27
57
  - !ruby/object:Gem::Dependency
28
58
  name: rake
29
59
  requirement: !ruby/object:Gem::Requirement
30
60
  requirements:
31
- - - "~>"
61
+ - - ~>
32
62
  - !ruby/object:Gem::Version
33
63
  version: '10.0'
34
64
  type: :development
35
65
  prerelease: false
36
66
  version_requirements: !ruby/object:Gem::Requirement
37
67
  requirements:
38
- - - "~>"
68
+ - - ~>
39
69
  - !ruby/object:Gem::Version
40
70
  version: '10.0'
41
71
  - !ruby/object:Gem::Dependency
42
72
  name: rspec
43
73
  requirement: !ruby/object:Gem::Requirement
44
74
  requirements:
45
- - - "~>"
75
+ - - ~>
46
76
  - !ruby/object:Gem::Version
47
77
  version: '3.0'
48
78
  type: :development
49
79
  prerelease: false
50
80
  version_requirements: !ruby/object:Gem::Requirement
51
81
  requirements:
52
- - - "~>"
82
+ - - ~>
53
83
  - !ruby/object:Gem::Version
54
84
  version: '3.0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: rubocop
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: 0.40.0
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.40.0
99
+ - !ruby/object:Gem::Dependency
100
+ name: yard
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: 0.9.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.9.0
55
113
  description: The cucloud module is intended to provide functionality requiring more
56
114
  customization than could otherwise be simply accomplished with a cloud specific
57
115
  command line interface, e.g. AWS CLI
58
116
  email:
59
117
  - shawn.bower@gmail.com
118
+ - bmh67@cornell.edu
119
+ - sr523@cornell.edu
60
120
  executables: []
61
121
  extensions: []
62
122
  extra_rdoc_files: []
63
123
  files:
64
- - ".gitignore"
65
- - ".rspec"
66
- - ".travis.yml"
124
+ - .gitignore
125
+ - .rspec
126
+ - .rubocop.yml
127
+ - .travis.yml
128
+ - .yardopts
67
129
  - CODE_OF_CONDUCT.md
68
130
  - Gemfile
69
131
  - README.md
@@ -72,7 +134,9 @@ files:
72
134
  - bin/setup
73
135
  - cucloud.gemspec
74
136
  - lib/cucloud.rb
137
+ - lib/cucloud/asg_utils.rb
75
138
  - lib/cucloud/ec2_utils.rb
139
+ - lib/cucloud/elb_utils.rb
76
140
  - lib/cucloud/version.rb
77
141
  homepage: https://github.com/CU-CloudCollab/cucloud_ruby
78
142
  licenses: []
@@ -83,17 +147,17 @@ require_paths:
83
147
  - lib
84
148
  required_ruby_version: !ruby/object:Gem::Requirement
85
149
  requirements:
86
- - - ">="
150
+ - - ! '>='
87
151
  - !ruby/object:Gem::Version
88
152
  version: '0'
89
153
  required_rubygems_version: !ruby/object:Gem::Requirement
90
154
  requirements:
91
- - - ">="
155
+ - - ! '>='
92
156
  - !ruby/object:Gem::Version
93
157
  version: '0'
94
158
  requirements: []
95
159
  rubyforge_project:
96
- rubygems_version: 2.2.2
160
+ rubygems_version: 2.4.5
97
161
  signing_key:
98
162
  specification_version: 4
99
163
  summary: The cucloud module is intended to provide functionality requiring more customization