jack-eb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2343df18ed2f47fd445ea515e7316062cd94bb15
4
+ data.tar.gz: 6e3b15ea572829141595e0725af3ab1caa084fbb
5
+ SHA512:
6
+ metadata.gz: 7aaf881febb1581159b83bcbb04be0a54340482d5ea7bcc7fcb4f42e627e53687f5abc626204275b2b98afeda8013d2edf87ad230b13f7a25104a823f3863cd6
7
+ data.tar.gz: 892740d93240d5cf75cbd18fd89f7f87ec16472e345fa9ea2032201790a15841690512a107ab44826e6f7d43c420be9537002fe52eb206b8cf6d1a4a4b718eb5
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ spec/fixtures/*/.elasticbeanstalk/saved_configs
18
+ spec/fixtures/fake.cfg.yml
19
+ spec/fixtures/project/.elasticbeanstalk/config.yml
20
+
21
+ # Elastic Beanstalk Files
22
+ .elasticbeanstalk/*
23
+ !.elasticbeanstalk/*.cfg.yml
24
+ !.elasticbeanstalk/*.global.yml
25
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jack.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jack-eb (0.0.1)
5
+ aws-sdk (~> 2)
6
+ colorize
7
+ thor
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ aws-sdk (2.0.29)
13
+ aws-sdk-resources (= 2.0.29)
14
+ aws-sdk-core (2.0.29)
15
+ builder (~> 3.0)
16
+ jmespath (~> 1.0)
17
+ multi_json (~> 1.0)
18
+ multi_xml (~> 0.5)
19
+ aws-sdk-resources (2.0.29)
20
+ aws-sdk-core (= 2.0.29)
21
+ builder (3.2.2)
22
+ celluloid (0.16.0)
23
+ timers (~> 4.0.0)
24
+ codeclimate-test-reporter (0.4.7)
25
+ simplecov (>= 0.7.1, < 1.0.0)
26
+ coderay (1.1.0)
27
+ colorize (0.7.5)
28
+ diff-lcs (1.2.5)
29
+ docile (1.1.5)
30
+ ffi (1.9.6)
31
+ formatador (0.2.5)
32
+ guard (2.12.4)
33
+ formatador (>= 0.2.4)
34
+ listen (~> 2.7)
35
+ lumberjack (~> 1.0)
36
+ nenv (~> 0.1)
37
+ notiffany (~> 0.0)
38
+ pry (>= 0.9.12)
39
+ shellany (~> 0.0)
40
+ thor (>= 0.18.1)
41
+ guard-bundler (2.1.0)
42
+ bundler (~> 1.0)
43
+ guard (~> 2.2)
44
+ guard-compat (~> 1.1)
45
+ guard-compat (1.2.1)
46
+ guard-rspec (4.5.0)
47
+ guard (~> 2.1)
48
+ guard-compat (~> 1.1)
49
+ rspec (>= 2.99.0, < 4.0)
50
+ hitimes (1.2.2)
51
+ jmespath (1.0.2)
52
+ multi_json (~> 1.0)
53
+ listen (2.8.5)
54
+ celluloid (>= 0.15.2)
55
+ rb-fsevent (>= 0.9.3)
56
+ rb-inotify (>= 0.9)
57
+ lumberjack (1.0.9)
58
+ method_source (0.8.2)
59
+ multi_json (1.10.1)
60
+ multi_xml (0.5.5)
61
+ nenv (0.2.0)
62
+ notiffany (0.0.6)
63
+ nenv (~> 0.1)
64
+ shellany (~> 0.0)
65
+ pry (0.10.1)
66
+ coderay (~> 1.1.0)
67
+ method_source (~> 0.8.1)
68
+ slop (~> 3.4)
69
+ rake (10.4.2)
70
+ rb-fsevent (0.9.4)
71
+ rb-inotify (0.9.5)
72
+ ffi (>= 0.5.0)
73
+ rspec (3.2.0)
74
+ rspec-core (~> 3.2.0)
75
+ rspec-expectations (~> 3.2.0)
76
+ rspec-mocks (~> 3.2.0)
77
+ rspec-core (3.2.1)
78
+ rspec-support (~> 3.2.0)
79
+ rspec-expectations (3.2.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.2.0)
82
+ rspec-mocks (3.2.1)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.2.0)
85
+ rspec-support (3.2.2)
86
+ shellany (0.0.1)
87
+ simplecov (0.9.2)
88
+ docile (~> 1.1.0)
89
+ multi_json (~> 1.0)
90
+ simplecov-html (~> 0.9.0)
91
+ simplecov-html (0.9.0)
92
+ slop (3.6.0)
93
+ thor (0.19.1)
94
+ timers (4.0.1)
95
+ hitimes
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ bundler (~> 1.3)
102
+ codeclimate-test-reporter
103
+ guard
104
+ guard-bundler
105
+ guard-rspec
106
+ jack-eb!
107
+ rake
@@ -0,0 +1,12 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { "spec/jack_spec.rb" }
4
+ watch(%r{^lib/jack/(.+)\.rb$}) { "spec/jack_spec.rb" }
5
+ watch('spec/spec_helper.rb') { "spec/jack_spec.rb" }
6
+ watch(%r{^lib/jack/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ end
8
+
9
+ guard 'bundler' do
10
+ watch('Gemfile')
11
+ watch(/^.+\.gemspec/)
12
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tung Nguyen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,135 @@
1
+ # Jack and the Elastic Beanstalk
2
+
3
+ [![Build Status](https://travis-ci.org/tongueroo/jack.svg?branch=master)](https://travis-ci.org/tongueroo/jack)
4
+ [![Code Climate](https://codeclimate.com/github/tongueroo/jack/badges/gpa.svg)](https://codeclimate.com/github/tongueroo/jack)
5
+ [![Test Coverage](https://codeclimate.com/github/tongueroo/jack/badges/coverage.svg)](https://codeclimate.com/github/tongueroo/jack)
6
+
7
+ Jack is a wrapper tool around the eb cli tool that can be use to manage AWS Elastic Beanstalk environments. It allows you to create environments based on a saved template configuration file, located in the jack/cfg folder of your project. It also provides a helpful config command to manage the template configuration.
8
+
9
+ For things that this tool does not do, it is recommended that you use use the underlying eb tool directly. This tool has been tested with the 3.1.2 version of the eb command, so have at least that version installed.
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ $ gem install jack-eb
15
+ ```
16
+
17
+ Note that the gem is called jack-eb but the command that is installed is called jack.
18
+
19
+ ### Setup
20
+
21
+ This gem relies on the eb cli tool. To install follow the instructions on [AWS EB Documentation](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-set-up.html). Here's the gist of it:
22
+
23
+ <pre>
24
+ $ sudo pip install awsebcli
25
+ </pre>
26
+
27
+ You need at least version 3.1.2 of the eb tool. To check the version `eb --version`. If you need to upgrade:
28
+
29
+ <pre>
30
+ $ sudo pip install --upgrade awsebcli
31
+ </pre>
32
+
33
+ You'll also need to set up your environment with your aws access keys since the tool also uses the aws-sdk. Add the following to your ~/.profile, replacing xxx with your actually credentials. Don't forgot to source the ~/.profile or open up a new terminal.
34
+
35
+ <pre>
36
+ export AWS_ACCESS_KEY_ID=xxx
37
+ export AWS_SECRET_ACCESS_KEY=xxx
38
+ </pre>
39
+
40
+ You're ready to go.
41
+
42
+ ## Usage
43
+
44
+ ### Overview
45
+
46
+ In your project folder create a folder call jack/cfg. It might be useful for your company to create a baseline config that you can use. If you do not already have a baseline template, you can download the template from an existing environment like so:
47
+
48
+ <pre>
49
+ $ jack config download [ENVIRONMENT_NAME]
50
+ </pre>
51
+
52
+ The path of config that is saved is based on a convention. An example best illustrates the convention.
53
+
54
+ <pre>
55
+ $ jack config download stag-rails-app-s1
56
+ Downloading config file...
57
+ Running: eb config save --cfg current-2015-03-03_18-40-34 stag-rails-app-s1
58
+
59
+ Configuration saved at: /Users/tung/src/rails/.elasticbeanstalk/saved_configs/current-2015-03-03_18-40-34.cfg.yml
60
+ Writing to local config file: jack/cfg/stag-rails-app.cfg.yml
61
+ Cleaning up eb remote config and local files
62
+ Config downloaded to jack/cfg/stag-rails-app.cfg.yml
63
+ $
64
+ </pre>
65
+
66
+ Results in a saved jack/cfg/stag-rails-app.cfg.yml template configuration file. Notice how the last dash separated word has been removed. The convention is overridable.
67
+
68
+ <pre>
69
+ $ jack config download -c myconfig stag-rails-app-s1
70
+ </pre>
71
+
72
+ Results in a saved jack/cfg/myconfig.cfg.yml template configuration file.
73
+
74
+ ### Creating Environments
75
+
76
+ The purpose of the jack/cfg configs is allow us to be able to create environments with a codified configuration file that can be versioned controlled.
77
+
78
+ <pre>
79
+ $ jack create stag-rails-app-s1 # uses the jack/cfg/stag-rails-app.cfg.yml template
80
+ $ jack create stag-rails-app-s2 # another instance of the environment, but still uses the jack/cfg/stag-rails-app.cfg.yml template
81
+ $ jack create -c myconfig stag-rails-app-s3 # creates environment using a config not based on naming convention
82
+ </pre>
83
+
84
+ If the project is brand new and has never had `eb init` ran on it before. For example, a project that has just been git cloned. Then calling any of the jack commands will automatically call `eb init` in the project. `eb init` requires the platform flag in order to avoid prompting. By default, the latest Docker solution stack is used for the platform option. But you can override that by creating an ~/.jack/create.yml or jack/create.yml within the project folder. Here's an [example](https://gist.github.com/tongueroo/086e3c11c4d00d5c39b6). The options from each file is merged using the following precedence: project folder, user home, default that is packaged with this gem. Most of the settings that `jack create` should used should be in the template configuration file though.
85
+
86
+ ### Downloading and Uploading Template Configurations
87
+
88
+ #### Download
89
+
90
+ To download a template configuration.
91
+
92
+ ```
93
+ $ jack config download stag-rails-app-s1
94
+ ```
95
+
96
+ This will save the config to jack/cfg/stag-rails-app.cfg.yml.
97
+
98
+ #### Upload
99
+
100
+ To upload a template configuration.
101
+
102
+ ```
103
+ $ jack config upload stag-rails-app-s1
104
+ ```
105
+
106
+ This will save the config to jack/cfg/stag-rails-app.cfg.yml. Here's an example of the [output](http://d.pr/i/14Sfh).
107
+
108
+ Notice that the `eb config upload` command also prompts you with the diff before uploading and ask for confirmation. You can bypass the prompt with the force option.
109
+
110
+ #### Diff - Comparing your local config to the live environment config
111
+
112
+ You can use the diff command directly to compare your local config to what configs the environment is actually using is useful. To see the diff.
113
+
114
+ ```
115
+ $ jack config diff stag-rails-app-s1
116
+ ```
117
+
118
+ A note about the configs. They are formatted so that the keys are sorted. This has been done so the diffs are actually useful. It is also recommended you install colordiff so you can see the diff output colorized. You can also specify your own diff viewer via the JACK_DIFF environment variable. Example of [colorized diff](http://d.pr/i/9wrS).
119
+
120
+ ### More Help
121
+
122
+ You can get help information from the CLI. Examples:
123
+
124
+ <pre>
125
+ $ jack help
126
+ $ jack help create
127
+ $ jack config help download
128
+ $ jack config help upload
129
+ $ jack config help upload
130
+ $ jack config help sort
131
+ </pre>
132
+
133
+ ### TODO
134
+
135
+ * encrypted the jack/cfg files similar to how [shopify/ejson](https://github.com/Shopify/ejson) works, except with yaml - pull requests are welcome
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :default => :spec
5
+
6
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ $:.unshift(File.expand_path('../../lib', __FILE__))
6
+ require 'jack'
7
+ require 'jack/cli'
8
+
9
+ Jack::CLI.start(ARGV)
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jack-eb"
8
+ spec.version = Jack::VERSION
9
+ spec.authors = ["Tung Nguyen"]
10
+ spec.email = ["tongueroo@gmail.com"]
11
+ spec.description = %q{Wrapper tool to manage AWS Elastic Beanstalk environments}
12
+ spec.summary = %q{Wrapper tool to manage AWS Elastic Beanstalk environments}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = ["jack"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor"
22
+ spec.add_dependency "colorize"
23
+ spec.add_dependency 'aws-sdk', '~> 2'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "guard"
28
+ spec.add_development_dependency "guard-bundler"
29
+ spec.add_development_dependency "guard-rspec"
30
+ end
@@ -0,0 +1,14 @@
1
+ $:.unshift(File.expand_path("../", __FILE__))
2
+ require "jack/version"
3
+ require "colorize"
4
+ require "aws-sdk"
5
+ require File.expand_path("../jack/ext/hash", __FILE__)
6
+
7
+ module Jack
8
+ autoload :CLI, 'jack/cli'
9
+ autoload :Create, 'jack/create'
10
+ autoload :Config, 'jack/config'
11
+ autoload :UI, 'jack/ui'
12
+ autoload :Util, 'jack/util'
13
+ autoload :VersionChecker, 'jack/version_checker'
14
+ end
@@ -0,0 +1,54 @@
1
+ require 'thor'
2
+ require 'jack/cli/help'
3
+ require 'jack/version_checker'
4
+ Jack::VersionChecker.new.run unless ENV['TEST']
5
+
6
+ module Jack
7
+ class ConfigCLI < Thor
8
+ desc "upload ENV_NAME", "upload and apply jack config changes to EB environment"
9
+ long_desc Jack::CLI::Help.upload
10
+ def upload(env_name)
11
+ Jack::Config::Upload.new(options.merge(env_name: env_name)).run
12
+ end
13
+
14
+ desc "download ENV_NAME", "downloads environment config to jack/cfg folder"
15
+ long_desc Jack::CLI::Help.download
16
+ option :dirty, type: :boolean, desc: "leave the remote eb config and download config behind"
17
+ def download(env_name)
18
+ Jack::Config::Download.new(options.merge(env_name: env_name)).run
19
+ end
20
+
21
+ desc "diff ENV_NAME", "diff jack config vs environment config"
22
+ long_desc Jack::CLI::Help.diff
23
+ option :dirty, type: :boolean, desc: "leave the remote eb config and download config behind"
24
+ def diff(env_name)
25
+ Jack::Config::Diff.new(options.merge(env_name: env_name)).run
26
+ end
27
+
28
+ desc "sort ENV_NAME", "reformat local jack config file to a sorted yaml file format"
29
+ long_desc Jack::CLI::Help.sort
30
+ def sort(env_name)
31
+ Jack::Config::Sort.new(options.merge(env_name: env_name)).run
32
+ end
33
+ end
34
+
35
+ class CLI < Thor
36
+ class_option :verbose, type: :boolean
37
+ class_option :mute, type: :boolean, desc: "mute all output, useful for specs"
38
+ class_option :noop, type: :boolean, desc: "dont run any destructive commands"
39
+ class_option :force, type: :boolean, desc: "bypass confirmation prompt"
40
+ class_option :root, :default => '.', desc: "root of the project, useful for specs"
41
+ class_option :cfg, aliases: :c, desc: "local config name if want to override the convention"
42
+ class_option :app, aliases: :a, desc: "app name if want to override the convention"
43
+
44
+ desc "create ENV_NAME", "create EB environment"
45
+ long_desc Help.create
46
+ def create(env_name)
47
+ Jack::Create.new(options.merge(env_name: env_name)).run
48
+ end
49
+
50
+ desc "config ACTION ENV_NAME", "manage environment config"
51
+ long_desc Help.config
52
+ subcommand "config", ConfigCLI
53
+ end
54
+ end