enscalator 0.4.0.pre.alpha.pre.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rubocop.yml +9 -0
  4. data/.rubocop_todo.yml +59 -0
  5. data/.travis.yml +22 -0
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +148 -0
  10. data/Rakefile +43 -0
  11. data/bin/console +11 -0
  12. data/bin/setup +7 -0
  13. data/enscalator.gemspec +57 -0
  14. data/exe/enscalator +13 -0
  15. data/lib/enscalator/core/cf_parameters.rb +146 -0
  16. data/lib/enscalator/core/cf_resources.rb +225 -0
  17. data/lib/enscalator/core/instance_type.rb +205 -0
  18. data/lib/enscalator/core/network_config.rb +21 -0
  19. data/lib/enscalator/core.rb +10 -0
  20. data/lib/enscalator/enapp.rb +248 -0
  21. data/lib/enscalator/helpers/dns.rb +62 -0
  22. data/lib/enscalator/helpers/stack.rb +107 -0
  23. data/lib/enscalator/helpers/sub_process.rb +72 -0
  24. data/lib/enscalator/helpers/wrappers.rb +55 -0
  25. data/lib/enscalator/helpers.rb +127 -0
  26. data/lib/enscalator/plugins/amazon_linux.rb +93 -0
  27. data/lib/enscalator/plugins/auto_scale.rb +80 -0
  28. data/lib/enscalator/plugins/core_os.rb +88 -0
  29. data/lib/enscalator/plugins/couchbase.rb +98 -0
  30. data/lib/enscalator/plugins/debian.rb +71 -0
  31. data/lib/enscalator/plugins/elastic_beanstalk.rb +74 -0
  32. data/lib/enscalator/plugins/elasticache.rb +168 -0
  33. data/lib/enscalator/plugins/elasticsearch_amazon.rb +75 -0
  34. data/lib/enscalator/plugins/elasticsearch_bitnami.rb +198 -0
  35. data/lib/enscalator/plugins/elasticsearch_opsworks.rb +225 -0
  36. data/lib/enscalator/plugins/elb.rb +139 -0
  37. data/lib/enscalator/plugins/nat_gateway.rb +71 -0
  38. data/lib/enscalator/plugins/rds.rb +141 -0
  39. data/lib/enscalator/plugins/redis.rb +38 -0
  40. data/lib/enscalator/plugins/rethink_db.rb +21 -0
  41. data/lib/enscalator/plugins/route53.rb +143 -0
  42. data/lib/enscalator/plugins/ubuntu.rb +85 -0
  43. data/lib/enscalator/plugins/user-data/elasticsearch +367 -0
  44. data/lib/enscalator/plugins/vpc_peering_connection.rb +48 -0
  45. data/lib/enscalator/plugins.rb +30 -0
  46. data/lib/enscalator/rich_template_dsl.rb +209 -0
  47. data/lib/enscalator/templates/vpc_peering.rb +112 -0
  48. data/lib/enscalator/templates.rb +20 -0
  49. data/lib/enscalator/version.rb +5 -0
  50. data/lib/enscalator/vpc.rb +11 -0
  51. data/lib/enscalator/vpc_with_nat_gateway.rb +311 -0
  52. data/lib/enscalator/vpc_with_nat_instance.rb +402 -0
  53. data/lib/enscalator.rb +103 -0
  54. metadata +427 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 56c12d72d43705f3c0dd5368c0a237ef07b17440
4
+ data.tar.gz: 051a15cfb748bf3d18687f0859d0871a9a536867
5
+ SHA512:
6
+ metadata.gz: 0c864f9ed600f5216906a630778d06cb8eca34882ce85156a258484cff0fca95c396e9db114a4e4dd4188b72c483e12db08bbb49b97f79712b0869a699f6273f
7
+ data.tar.gz: d771e4ebdd6d994ab8dea52e817de195c9461ff3efc22cb83850febe0de56991b6cd1e679fcb5e4a0854c2906da46e8b877d6f441b215fd68737dec704de728b
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.DS_S*
2
+ /.bundle/
3
+ /vendor/bundle
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ .*.swp
13
+ /.idea
14
+ *.iml
15
+ /.bin
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+ require: rubocop-rspec
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - vendor/**/*
8
+ - tools/openvpn/**/*
9
+ - lib/enscalator/templates/**/*
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,59 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-12-23 23:28:02 +0900 using RuboCop version 0.33.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 27
10
+ Metrics/AbcSize:
11
+ Max: 110
12
+
13
+ # Offense count: 3
14
+ # Configuration parameters: CountComments.
15
+ Metrics/ClassLength:
16
+ Max: 400
17
+
18
+ # Offense count: 6
19
+ Metrics/CyclomaticComplexity:
20
+ Max: 20
21
+
22
+ # Offense count: 403
23
+ # Configuration parameters: AllowURI, URISchemes.
24
+ Metrics/LineLength:
25
+ Max: 129
26
+
27
+ # Offense count: 41
28
+ # Configuration parameters: CountComments.
29
+ Metrics/MethodLength:
30
+ Max: 400
31
+
32
+ # Offense count: 4
33
+ # Configuration parameters: CountComments.
34
+ Metrics/ModuleLength:
35
+ Max: 250
36
+
37
+ # Offense count: 13
38
+ # Configuration parameters: CountKeywordArgs.
39
+ Metrics/ParameterLists:
40
+ Max: 10
41
+
42
+ # Offense count: 4
43
+ Metrics/PerceivedComplexity:
44
+ Max: 22
45
+
46
+ # Offense count: 8
47
+ Style/AccessorMethodName:
48
+ Exclude:
49
+ - 'lib/enscalator/enapp.rb'
50
+
51
+ # Offense count: 3
52
+ Style/RescueModifier:
53
+ Exclude:
54
+ - 'lib/enscalator/enapp.rb'
55
+
56
+ # Offense count: 1
57
+ Style/FlipFlop:
58
+ Exclude:
59
+ - 'lib/enscalator/plugins/debian.rb'
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.2.1
5
+ script: bundle exec rake test
6
+ notifications:
7
+ email: false
8
+ env:
9
+ global:
10
+ - secure: "LUUnEhX/N8+0N4QB4hw0T5Ln+jV1JBsF5SR+ba0rTkfcY/lRXkhqxGZD7P5eJrIiX00ojjyuExQ0ACLnoMW+ZvAs6P1UvT2cfzvSuT0acMQWIj01M2X3iDEU9fovr3VZVD55rIO2EukjXxqtmm6SXng0ns7hjMu5qrpBBz/XonuDJeYpRlq6v1RhXpM5IJbCf36tx/wxrS37cerX/oXHXnASH0BqW2m3mncOLLb9xdwGj9GQShwTFkrk64jHP+lCRR1L0lYes9wNEzMayIOzNThyTVBYMP7Og19hRQMXU7USmW6sqiXIAV9OR6Mw44NsoUzgifzmcpG44lldutgBEvDGC3KauEZALFlUl6wV5Ccp0JBY+dKUaiP5kyAWJtI4HYkWkn/f2urENcmS2pzMBi7Tx2pvFpuDLXdDQR4BzW+53kVSqXJU98FByjg6DX13PYchcV4jb/CYheM6ZoKRWhAAc+S75tCA3uCeJjGoiuK3FHZvnjDQzOIJh66EA2AHqxj0FWyKVn1BGdA3y0jK5suyAXiVdSIfqFiTRVEKvUf3J3tzxhriWT/RPMTjsYEGvNTSZKhuUYlIZ4SxDaMgqQajQMoAgSXJ4VUkPv/faIZwYIl3H8KuMI9wsjU4+k+ZDyUzOx4xnze1gCW6on8TYo806uOiOUhL5q1VnBYckrY="
11
+ deploy_rubygems: &deploy_rubygems
12
+ provider: rubygems
13
+ api_key:
14
+ secure: "bfgS0ra7Yi/60/eH+sxUspst0iA5j7Ez6jA58PIzPn/mXE47gM0f7vEI/yCLshxzpepoQZGW+XWPHMwerVTl6B31RP2ShMjggxIgOs703HQpElZ5E9T2/hz87CTvMRyp/ZSTwWnhjcqnbRGQvXohv/e6HmYOU08GztmvVlM3saweIUSrZUWgnfQvytY6BRmCsoknWnAJw0ikazVaQOURszQRS88xbZO+FraBMMDDCQlmyvptOkDnMNGDZXj760LCUKb4R0BgwfVNT0L/fOL/wEX+OMYGlTXfdYI6F8EZA41QbwUXij8d0okZr9TzsLAg//q4QHEWZKhEsmGP2nyo20z33ke/OD6eUA6e4EP5qH9kuRneHKCVrnyge9f/fNktfm/RdRYb4FGXiNR2o0Nv0ibXaKCY+HLW8FLXoEgHY8Re7GoFgsHE9qGD4Vs4n2sHPRU1uQRUMlVtZ43QLlUOII8q9Fu4NvzZfkNAtb4KhZQXtxPt8TQgrshMy420hv4Ve1Oc21D+3lnS2SYykX1v+b0eoU3vHzl+3cLpMUOvDRhwAWH1dZ0mOi2YNG+wwgK8gFjxpUHDAfTHCW9bims5KPUAsCWC9FWwuM1sm2glDPbddzomZjyvt0EkBv2k2mPOSx8JWTvZuCKPMmOuCA86g08U/ArqM0KDEqxg2H55FSk="
15
+ deploy:
16
+ <<: *deploy_rubygems
17
+ on:
18
+ tags: true
19
+ deploy:
20
+ <<: *deploy_rubygems
21
+ on:
22
+ branch: master
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # All gem dependencies are specified in enscalator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 AIR at en-japan inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # Enscalator
2
+
3
+ [![Build Status](https://travis-ci.org/en-japan-air/enscalator.svg?branch=master)](https://travis-ci.org/en-japan-air/enscalator)
4
+ [![Coverage Status](https://coveralls.io/repos/github/en-japan-air/enscalator/badge.svg?branch=master)](https://coveralls.io/github/en-japan-air/enscalator?branch=master)
5
+ [![Inline docs](http://inch-ci.org/github/en-japan-air/enscalator.svg?branch=master)](http://inch-ci.org/github/en-japan-air/enscalator)
6
+
7
+ Enscalator is based on [bazaarvoice/cloudformation-ruby-dsl](https://github.com/bazaarvoice/cloudformation-ruby-dsl)
8
+ and helps cloudforming applications created by AIR at en-japan inc.
9
+
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'enscalator'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install enscalator
26
+
27
+ ## Usage
28
+
29
+ ### CLI
30
+
31
+ ```bash
32
+ $ enscalator -h
33
+ Usage: enscalator [arguments]
34
+ -l, --list-templates List all available templates
35
+ -t, --template=<s> Template name
36
+ -f, --template-file=<s> Template filename
37
+ -r, --region=<s> AWS Region (default: us-east-1)
38
+ -p, --parameters=<s> Parameters 'Key1=Value1;Key2=Value2'
39
+ -s, --stack-name=<s> Stack name
40
+ -z, --private-hosted-zone=<s> Private hosted zone (e.x. 'default-vpc.internal')
41
+ -g, --public-hosted-zone=<s> Public hosted zone
42
+ -c, --create-stack Create the stack
43
+ -u, --update-stack Update already deployed stack
44
+ -e, --pre-run, --no-pre-run Use pre-run hooks (default: true)
45
+ -o, --post-run, --no-post-run Use post-run hooks (default: true)
46
+ -x, --expand Print generated JSON template
47
+ -a, --capabilities=<s> AWS capabilities (default: CAPABILITY_IAM)
48
+ -n, --vpc-stack-name=<s> VPC stack name (default: default-vpc)
49
+ -d, --availability-zone=<s> Deploy to specific availability zone (default: all)
50
+ -i, --profile=<s> Use a specific profile from your credential file
51
+ -h, --help Show this message
52
+ ```
53
+
54
+ Examples:
55
+
56
+ Create new stack with name `en-japan-air-vpc` in `us-west-1`
57
+
58
+ ```bash
59
+ $ enscalator -t VPC -r us-west-1 -s en-japan-air-vpc -d a -c
60
+ ```
61
+
62
+ > Note: if you'd like to run enscalator directly inside gem repository, use `./exe/enscalator` script.
63
+
64
+ ### Autogenerated ssh keys for ec2 instances
65
+
66
+ All autogenerated ssh keys gets saved to directory corresponding to the selected profile name under user home
67
+ directory at `$HOME/.enscalator`, thus:
68
+
69
+ * when no profile option was given, keys would be saved to `$HOME/.enscalator/default`
70
+ * for specific profile, directory will be created automatically and all keys gets saved under `$HOME/.enscalator/%profile_name%`
71
+
72
+ ### How to write a template
73
+
74
+ All enscalator templates are stored in `lib/enscalator/templates/`.
75
+ Application specific templates can be saved in any file and deployed by enscalator using `--template-file`.
76
+
77
+ You'll find the list of helpers you can use in:
78
+
79
+ * `lib/enscalator/richtemplate.rb`
80
+ * `lib/enscalator/core/cf_parameters.rb`
81
+ * `lib/enscalator/core/cf_resources.rb`
82
+ * `lib/enscalator/enapp.rb`
83
+ * `lib/enscalator/helpers.rb` (and more generic helpers)
84
+
85
+ Note: for each template based on `EnAppTemplateDSL` you'll automatically get autogenerated
86
+ `ResourceSecurityGroup`, `ApplicationSecurityGroup` and load balancer along with `ResourceSubnet` and `ApplicationSubnet`
87
+ for each availability zone (for example, in case of zone `a` it would be `ResourceSubnetA` and `ApplicationSubnetA` and so on).
88
+ Since this setup relies on presence of `VPC` of specific setup it is required to deploy `VPC` template prior to
89
+ deploying any template based on `EnAppTemplateDSL`.
90
+
91
+ Check [lib/enscalator/templates/vpc_peering.rb](lib/enscalator/templates/vpc_peering.rb) for an example.
92
+
93
+
94
+ ### How to write a plugin and include it?
95
+
96
+ Plugins are modules and stored in `lib/enscalator/plugins/`.
97
+ When you want to use your plugin you just have to `include PluginName` inside your template.
98
+ See `lib/enscalator/plugins/vpc_peering_connection.rb` for an example.
99
+ Don't forget to `require_relative` your new plugin in `lib/enscalator/plugins.rb`.
100
+
101
+ Plugins supported out of the box:
102
+
103
+ * [AmazonLinux](lib/enscalator/plugins/amazon_linux.rb)
104
+ * [AutoScale](lib/enscalator/plugins/auto_scale.rb)
105
+ * [CoreOS](lib/enscalator/plugins/core_os.rb)
106
+ * [Couchbase](lib/enscalator/plugins/couchbase.rb)
107
+ * [Debian](lib/enscalator/plugins/debian.rb)
108
+ * [ElasticBeanstalk](lib/enscalator/plugins/elastic_beanstalk.rb)
109
+ * [Elasticache](lib/enscalator/plugins/elasticache.rb)
110
+ * [ElasticsearchAmazon](lib/enscalator/plugins/elasticsearch_amazon.rb)
111
+ * [ElasticsearchBitnami](lib/enscalator/plugins/elasticsearch_bitnami.rb)
112
+ * [ElasticsearchOpsworks](lib/enscalator/plugins/elasticsearch_opsworks.rb)
113
+ * [Elb](lib/enscalator/plugins/elb.rb)
114
+ * [NATGateway](lib/enscalator/plugins/nat_gateway.rb)
115
+ * [RDS](lib/enscalator/plugins/rds.rb)
116
+ * [Redis](lib/enscalator/plugins/redis.rb)
117
+ * [RethinkDB](lib/enscalator/plugins/rethink_db.rb)
118
+ * [Route53](lib/enscalator/plugins/route53.rb)
119
+ * [Ubuntu](lib/enscalator/plugins/ubuntu.rb)
120
+ * [VPCPeeringConnection](lib/enscalator/plugins/vpc_peering_connection.rb)
121
+
122
+
123
+ #### What's pre_run and post_run?
124
+
125
+ **pre_run** is a method called **BEFORE** the template generation. It's a good place to make some calls to the AWS SDK for instance.
126
+ **post_run** is a method called **AFTER** the stack is created.
127
+
128
+
129
+ ## Development
130
+
131
+ To install this gem onto your local machine, run `bundle && bundle exec rake install`.
132
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`
133
+ to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
134
+
135
+
136
+ ## Documentation
137
+
138
+ To generate documentation run `rake doc` ( or `bundle exec rake doc` )
139
+
140
+
141
+ ## Contributing
142
+
143
+ 1. Fork it ( https://github.com/en-japan-air/enscalator/fork )
144
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
145
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
146
+ 4. Push to the branch (`git push origin my-new-feature`)
147
+ 5. Check if tests failing (`rake spec` or `bundle exec rake spec`)
148
+ 6. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+ require 'yard'
4
+ require 'rubocop/rake_task'
5
+
6
+ # Testing with rspec
7
+ RSpec::Core::RakeTask.new(:spec) do |task|
8
+ task.rspec_opts = %w(--color --format documentation)
9
+ end
10
+ task test: :spec
11
+
12
+ # Generate documentation with yard
13
+ YARD::Rake::YardocTask.new do |t|
14
+ t.files = %w(lib/*.rb lib/enscalator/*.rb lib/enscalator/plugins/*.rb)
15
+ t.stats_options = %w(--list-undoc --compact)
16
+ end
17
+ desc 'Generate gem documentation (same as running "rake yard")'
18
+ task doc: :yard
19
+
20
+ # Print all available plugins
21
+ namespace :enscalator do
22
+ namespace :plugins do
23
+ desc 'Show all available plugins'
24
+ task :show do
25
+ require 'enscalator'
26
+ root_dir = Pathname.new('lib/enscalator')
27
+ plugins = Enscalator::Plugins.constants
28
+ # print pairs of plugin module name / filename
29
+ root_dir.join('plugins').children.select { |p| p.to_s.end_with?('.rb') }.each do |plugin_file|
30
+ plugin_module = plugins.find { |p| p.to_s.underscore == File.basename(plugin_file, '.rb').to_s }
31
+ STDOUT.puts "Enscalator::Plugins::#{plugin_module} (#{plugin_file})"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ # Use RuboCop to check for code/style offenses
38
+ desc 'Run RuboCop on the lib directory'
39
+ RuboCop::RakeTask.new(:rubocop) do |task|
40
+ # don't abort rake on failure
41
+ task.fail_on_error = false
42
+ end
43
+ task default: [:rubocop, :spec]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'enscalator'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # Use Pry by default
10
+ require 'pry'
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install --path vendor/bundle
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,57 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'enscalator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'enscalator'
8
+ spec.version = Enscalator::VERSION
9
+ spec.description = 'Webscale applications from AIR at en-japan inc.'
10
+ spec.summary = 'Make apps created by AIR at en-japan inc. really webscale.'
11
+ spec.license = 'MIT'
12
+ spec.authors = ['Ugo Bataillard', 'Denis Vazhenin', 'David Hagege', 'Yongyu Lee', 'Junji Watanabe']
13
+ spec.email = ['ugo@bataillard.me',
14
+ 'denis.vazhenin@me.com',
15
+ 'david.hagege@gmail.com',
16
+ 'aleeyyu+01@gmail.com',
17
+ 'watanabe0621@gmail.com']
18
+ spec.required_ruby_version = '~> 2.0'
19
+ spec.homepage = 'https://www.github.com/en-japan-air/enscalator'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.8'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'pry', '~> 0.10.1'
29
+ spec.add_development_dependency 'pry-byebug', '~> 3.4.0'
30
+ spec.add_development_dependency 'awesome_print', '~> 1.6.1'
31
+ spec.add_development_dependency 'looksee', '~> 3.1.0'
32
+ spec.add_development_dependency 'yard', '~> 0.8.7.6'
33
+ spec.add_development_dependency 'vcr', '~> 2.9.3'
34
+ spec.add_development_dependency 'webmock', '~> 1.21.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.2.0'
36
+ spec.add_development_dependency 'rspec-expectations', '~> 3.2.0'
37
+ spec.add_development_dependency 'rspec-mocks', '~> 3.2.1'
38
+ spec.add_development_dependency 'rubocop', '~> 0.47.1'
39
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.10.0'
40
+ spec.add_development_dependency 'coveralls', '~> 0.8.19'
41
+
42
+ spec.add_runtime_dependency 'aws-sdk', '2.1.36'
43
+ spec.add_runtime_dependency 'cloudformation-ruby-dsl', '~> 1.0'
44
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6.6.2'
45
+ spec.add_runtime_dependency 'trollop', '~> 2.1'
46
+ spec.add_runtime_dependency 'activesupport', '~> 4.2'
47
+ spec.add_runtime_dependency 'ipaddress', '~> 0.8'
48
+ spec.add_runtime_dependency 'semantic', '~> 1.4.0'
49
+ spec.add_runtime_dependency 'ruby-progressbar', '~> 1.7.5'
50
+
51
+ # Create pre-release version unless it is a tag
52
+ if ENV['TRAVIS']
53
+ if ENV['TRAVIS_TAG'].nil? || ENV['TRAVIS_TAG'].empty?
54
+ spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}"
55
+ end
56
+ end
57
+ end
data/exe/enscalator ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # TODO: remove once enscalator can be used as standalone gem
4
+ # Workaround to keep this script working, i.e. when it
5
+ # executed directly from codebase like './exe/enscalator'
6
+ begin
7
+ Object.const_get('Enscalator')
8
+ rescue NameError
9
+ require 'bundler/setup'
10
+ end
11
+ require 'enscalator'
12
+
13
+ Enscalator.run!(ARGV)
@@ -0,0 +1,146 @@
1
+ module Enscalator
2
+ module Core
3
+ # Parameters for cloudformation template dsl
4
+ module CfParameters
5
+ # Key name parameter
6
+ #
7
+ # @param [String] instance_name for which ssh key was created
8
+ def parameter_key_name(instance_name)
9
+ parameter "#{instance_name}KeyName",
10
+ Description: "Name of the #{instance_name} ssh key pair",
11
+ Type: 'String',
12
+ MinLength: '1',
13
+ MaxLength: '64',
14
+ AllowedPattern: '[a-zA-Z][-_a-zA-Z0-9]*',
15
+ ConstraintDescription: 'can contain only alphanumeric characters, dashes and underscores.'
16
+ end
17
+
18
+ # Name parameter
19
+ #
20
+ # @param [String] instance_name instance name
21
+ # @param [String] default default name
22
+ # @param [Integer] min_length minimum length
23
+ # @param [Integer] max_length maximum length
24
+ def parameter_name(instance_name, default: nil, min_length: 1, max_length: 64)
25
+ parameter "#{instance_name}Name",
26
+ Default: default ? default.to_s : "#{instance_name}",
27
+ Description: "#{instance_name} name",
28
+ Type: 'String',
29
+ MinLength: min_length,
30
+ MaxLength: max_length,
31
+ AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
32
+ ConstraintDescription: 'must begin with a letter and contain only alphanumeric characters.'
33
+ end
34
+
35
+ # Username parameter
36
+ #
37
+ # @param [String] instance_name instance name
38
+ # @param [String] default default username
39
+ # @param [Integer] min_length minimum length
40
+ # @param [Integer] max_length maximum length
41
+ def parameter_username(instance_name, default: 'root', min_length: 1, max_length: 16)
42
+ parameter "#{instance_name}Username",
43
+ Default: default,
44
+ NoEcho: 'true',
45
+ Description: "Username for #{instance_name} access",
46
+ Type: 'String',
47
+ MinLength: min_length,
48
+ MaxLength: max_length,
49
+ AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
50
+ ConstraintDescription: 'must begin with a letter and contain only alphanumeric characters.'
51
+ end
52
+
53
+ # Password parameter
54
+ #
55
+ # @param [String] instance_name instance name
56
+ # @param [String] default default value
57
+ # @param [Integer] min_length minimum length
58
+ # @param [Integer] max_length maximum length
59
+ def parameter_password(instance_name, default: 'password', min_length: 8, max_length: 41)
60
+ parameter "#{instance_name}Password",
61
+ Default: default,
62
+ NoEcho: 'true',
63
+ Description: "Password for #{instance_name} access",
64
+ Type: 'String',
65
+ MinLength: min_length,
66
+ MaxLength: max_length,
67
+ AllowedPattern: '[a-zA-Z0-9]*',
68
+ ConstraintDescription: 'must contain only alphanumeric characters.'
69
+ end
70
+
71
+ # Allocated storage parameter
72
+ #
73
+ # @param [String] instance_name instance name
74
+ # @param [String] default size of instance primary storage
75
+ # @param [Integer] min minimal allowed value
76
+ # @param [Integer] max maximum allowed value
77
+ def parameter_allocated_storage(instance_name, default: 5, min: 5, max: 1024)
78
+ parameter "#{instance_name}AllocatedStorage",
79
+ Default: default.to_s,
80
+ Description: "The size of the #{instance_name} (Gb)",
81
+ Type: 'Number',
82
+ MinValue: min.to_s,
83
+ MaxValue: max.to_s,
84
+ ConstraintDescription: "must be between #{min} and #{max}Gb."
85
+ end
86
+
87
+ # Ami image parameter
88
+ #
89
+ # @param [String] name ami of the ami
90
+ # @param [String] ami_id id of the ami
91
+ # @return [String] parameter name
92
+ def parameter_ami(name, ami_id)
93
+ parameter_name = "#{name}AMIId"
94
+ parameter parameter_name,
95
+ Default: ami_id,
96
+ Description: "The #{name} AMI id",
97
+ Type: 'String',
98
+ AllowedPattern: 'ami-[a-zA-Z0-9]*',
99
+ ConstraintDescription: 'must be valid AMI id (ami-*).'
100
+ parameter_name
101
+ end
102
+
103
+ # Instance type parameter
104
+ #
105
+ # @param [String] instance_name instance name
106
+ # @param [String] type instance type (default: t2.micro)
107
+ # @param [Array] allowed_values list used to override built-in instance types
108
+ def parameter_instance_type(instance_name, type, allowed_values: [])
109
+ # check if given type is included in allowed_values and fails if none matched
110
+ unless allowed_values.any? { |v| v == type }
111
+ fail("Instance type \"#{type}\" is not in allowed values: #{allowed_values.join(' ')}")
112
+ end
113
+ name = "#{instance_name}InstanceType"
114
+ parameter name,
115
+ Default: type,
116
+ Description: "The #{instance_name} instance type",
117
+ Type: 'String',
118
+ AllowedValues: allowed_values,
119
+ ConstraintDescription: 'must be valid EC2 instance type.'
120
+ name
121
+ end
122
+
123
+ # EC2 Instance type parameter
124
+ #
125
+ # @param [String] instance_name name of the instance
126
+ # @param [String] type instance type
127
+ def parameter_ec2_instance_type(instance_name,
128
+ type: InstanceType.ec2_instance_type.current_generation[:general_purpose].first)
129
+ fail("Not supported instance type: #{type}") unless InstanceType.ec2_instance_type.supported?(type)
130
+ warn("Using obsolete instance type: #{type}") if InstanceType.ec2_instance_type.obsolete?(type)
131
+ parameter_instance_type(instance_name, type, allowed_values: InstanceType.ec2_instance_type.allowed_values(type))
132
+ end
133
+
134
+ # RDS Instance type parameter
135
+ #
136
+ # @param [String] instance_name name of the instance
137
+ # @param [String] type instance type
138
+ def parameter_rds_instance_type(instance_name,
139
+ type: InstanceType.rds_instance_type.current_generation[:general_purpose].first)
140
+ fail("Not supported instance type: #{type}") unless InstanceType.rds_instance_type.supported?(type)
141
+ warn("Using obsolete instance type: #{type}") if InstanceType.rds_instance_type.obsolete?(type)
142
+ parameter_instance_type(instance_name, type, allowed_values: InstanceType.rds_instance_type.allowed_values(type))
143
+ end
144
+ end
145
+ end
146
+ end