jellyfish_fog_aws 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +11 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.md +1 -0
- data/Rakefile +11 -0
- data/bin/rails +12 -0
- data/config/initializers/fog.rb +3 -0
- data/config/initializers/product_types.rb +6 -0
- data/config/initializers/provisioners.rb +8 -0
- data/config/product_questions/database.json +53 -0
- data/config/product_questions/infrastructure.json +23 -0
- data/config/product_questions/storage.json +31 -0
- data/config/provisioners.json +5 -0
- data/db/migrate/20150309142220_create_jellyfish_fog_aws_database_products.rb +12 -0
- data/db/migrate/20150309181621_create_jellyfish_fog_aws_infrastructure_products.rb +9 -0
- data/db/migrate/20150309192000_create_jellyfish_fog_aws_storage_products.rb +9 -0
- data/doc/aws_database.json +52 -0
- data/doc/aws_infrastructure.json +22 -0
- data/doc/aws_storage.json +30 -0
- data/jellyfish_fog_aws.gemspec +29 -0
- data/lib/jellyfish_fog_aws.rb +13 -0
- data/lib/jellyfish_fog_aws/databases.rb +56 -0
- data/lib/jellyfish_fog_aws/engine.rb +9 -0
- data/lib/jellyfish_fog_aws/infrastructure.rb +47 -0
- data/lib/jellyfish_fog_aws/storage.rb +40 -0
- data/lib/jellyfish_fog_aws/version.rb +7 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/provisioner.rb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/migrate/20150406223805_create_jellyfish_fog_aws_database_products.jellyfish_fog_aws.rb +13 -0
- data/spec/dummy/db/migrate/20150406223806_create_jellyfish_fog_aws_infrastructure_products.jellyfish_fog_aws.rb +10 -0
- data/spec/dummy/db/migrate/20150406223807_create_jellyfish_fog_aws_storage_products.jellyfish_fog_aws.rb +10 -0
- data/spec/dummy/db/schema.rb +43 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/jellyfish_fog_aws_spec.rb +13 -0
- data/spec/lib/jellyfish_fog_aws/databases_spec.rb +46 -0
- data/spec/lib/jellyfish_fog_aws/infrastructure_spec.rb +35 -0
- data/spec/lib/jellyfish_fog_aws/storage_spec.rb +36 -0
- data/spec/spec_helper.rb +25 -0
- metadata +255 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28cce5e618077c5fdc7e5ffb30b8ebabf5e06338
|
4
|
+
data.tar.gz: c6d3faa989ae952888419956b128c130c1dba5ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 863ea4f5d0917def83dbdc651204abd6e5452cf49ea1380beb151d1ca04f8ccb6fadbd6e748fb92553246634a271870615e053003d8386ed011ac0470b33a78e
|
7
|
+
data.tar.gz: d6d4be08c05d3ff65f2920296512d19a9fe1bd2899a0fa6b5636d50c079be9d56c2601d956d281e6e34964cb1e2a48eedf5a492027ff3dc92a645122bca1ab0c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in jellyfish_fog_aws.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# JellyfishFogAws
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
task default: :spec
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/jellyfish_fog_aws/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'jellyfish_fog_aws/databases'
|
2
|
+
require 'jellyfish_fog_aws/infrastructure'
|
3
|
+
require 'jellyfish_fog_aws/storage'
|
4
|
+
|
5
|
+
Rails.application.config.x.provisioners.merge!(
|
6
|
+
JSON.parse(File.read(Jellyfish::Fog::AWS::Engine.root.join('config', 'provisioners.json')))
|
7
|
+
.map { |product_type, provisioner| [product_type, provisioner.constantize] }.to_h
|
8
|
+
)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "AWS Fog Databases",
|
4
|
+
"description": "AWS Fog Databases",
|
5
|
+
"required": ["DBInstanceClass", "Engine", "AllocatedStorage"],
|
6
|
+
"properties": {
|
7
|
+
"DBInstanceClass": {
|
8
|
+
"title": "DB Instance Size",
|
9
|
+
"type": "string",
|
10
|
+
"enum": [
|
11
|
+
"db.m3.medium",
|
12
|
+
"db.m3.large",
|
13
|
+
"db.m3.xlarge"
|
14
|
+
],
|
15
|
+
"default": "db.m3.medium"
|
16
|
+
},
|
17
|
+
"Engine": {
|
18
|
+
"title": "DB Engine",
|
19
|
+
"type": "string",
|
20
|
+
"enum": [
|
21
|
+
"aurora",
|
22
|
+
"mysql",
|
23
|
+
"postgresql",
|
24
|
+
"sqlserver"
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"AllocatedStorage": {
|
28
|
+
"title": "Disk Size",
|
29
|
+
"type": "string",
|
30
|
+
"default": "40"
|
31
|
+
},
|
32
|
+
"StorageType": {
|
33
|
+
"title": "Storage Type",
|
34
|
+
"type": "string",
|
35
|
+
"enum": [
|
36
|
+
"ssd",
|
37
|
+
"standard",
|
38
|
+
"gp2",
|
39
|
+
"io1"
|
40
|
+
],
|
41
|
+
"default": "ssd"
|
42
|
+
},
|
43
|
+
"availability": {
|
44
|
+
"title": "Storage Redundancy",
|
45
|
+
"type": "string",
|
46
|
+
"enum": [
|
47
|
+
"normal",
|
48
|
+
"reduced"
|
49
|
+
],
|
50
|
+
"default": "normal"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Infrastructure",
|
4
|
+
"description": "AWS Fog Infrastructure",
|
5
|
+
"required": ["instance_size", "disk_size"],
|
6
|
+
"properties": {
|
7
|
+
"instance_size": {
|
8
|
+
"title": "Instance Size",
|
9
|
+
"type": "string",
|
10
|
+
"enum": [
|
11
|
+
"t2.micro",
|
12
|
+
"m3.medium",
|
13
|
+
"m3.large"
|
14
|
+
],
|
15
|
+
"default": "m3.medium"
|
16
|
+
},
|
17
|
+
"disk_size": {
|
18
|
+
"title": "Disk Size",
|
19
|
+
"type": "string",
|
20
|
+
"default": "40"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Storage",
|
4
|
+
"title": "AWS Fog Storage",
|
5
|
+
"required": ["availability", "region"],
|
6
|
+
"properties": {
|
7
|
+
"availability": {
|
8
|
+
"title": "Storage Redundancy",
|
9
|
+
"type": "string",
|
10
|
+
"enum": [
|
11
|
+
"normal",
|
12
|
+
"reduced"
|
13
|
+
],
|
14
|
+
"default": "normal"
|
15
|
+
},
|
16
|
+
"region": {
|
17
|
+
"title": "DB Engine",
|
18
|
+
"type": "string",
|
19
|
+
"enum": [
|
20
|
+
"",
|
21
|
+
"us-west-1",
|
22
|
+
"us-west-2",
|
23
|
+
"EU",
|
24
|
+
"ap-northeast-1",
|
25
|
+
"ap-southeast-1",
|
26
|
+
"ap-southeast-2"
|
27
|
+
],
|
28
|
+
"default": ""
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateJellyfishFogAwsDatabaseProducts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :jellyfish_fog_aws_database_products do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.string :db_instance_class
|
6
|
+
t.string :engine
|
7
|
+
t.string :allocated_storage
|
8
|
+
t.string :storage_type
|
9
|
+
t.string :availability
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Databases",
|
4
|
+
"required": ["db_instance_class", "engine", "allocated_storage"],
|
5
|
+
"properties": {
|
6
|
+
"db_instance_class": {
|
7
|
+
"title": "DB Instance Size",
|
8
|
+
"type": "string",
|
9
|
+
"enum": [
|
10
|
+
"db.m3.medium",
|
11
|
+
"db.m3.large",
|
12
|
+
"db.m3.xlarge"
|
13
|
+
],
|
14
|
+
"default": "db.m3.medium"
|
15
|
+
},
|
16
|
+
"engine": {
|
17
|
+
"title": "DB Engine",
|
18
|
+
"type": "string",
|
19
|
+
"enum": [
|
20
|
+
"aurora",
|
21
|
+
"mysql",
|
22
|
+
"postgresql",
|
23
|
+
"sqlserver"
|
24
|
+
]
|
25
|
+
},
|
26
|
+
"allocated_storage": {
|
27
|
+
"title": "Disk Size",
|
28
|
+
"type": "string",
|
29
|
+
"default": "40"
|
30
|
+
},
|
31
|
+
"storage_type": {
|
32
|
+
"title": "Storage Type",
|
33
|
+
"type": "string",
|
34
|
+
"enum": [
|
35
|
+
"ssd",
|
36
|
+
"standard",
|
37
|
+
"gp2",
|
38
|
+
"io1"
|
39
|
+
],
|
40
|
+
"default": "ssd"
|
41
|
+
},
|
42
|
+
"availability": {
|
43
|
+
"title": "Storage Redundancy",
|
44
|
+
"type": "string",
|
45
|
+
"enum": [
|
46
|
+
"normal",
|
47
|
+
"reduced"
|
48
|
+
],
|
49
|
+
"default": "normal"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Databases",
|
4
|
+
"required": ["instance_size", "disk_size"],
|
5
|
+
"properties": {
|
6
|
+
"instance_size": {
|
7
|
+
"title": "Instance Size",
|
8
|
+
"type": "string",
|
9
|
+
"enum": [
|
10
|
+
"t2.micro",
|
11
|
+
"m3.medium",
|
12
|
+
"m3.large"
|
13
|
+
],
|
14
|
+
"default": "m3.medium"
|
15
|
+
},
|
16
|
+
"disk_size": {
|
17
|
+
"title": "Disk Size",
|
18
|
+
"type": "string",
|
19
|
+
"default": "40"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Storage",
|
4
|
+
"required": ["availability", "region"],
|
5
|
+
"properties": {
|
6
|
+
"availability": {
|
7
|
+
"title": "Storage Redundancy",
|
8
|
+
"type": "string",
|
9
|
+
"enum": [
|
10
|
+
"normal",
|
11
|
+
"reduced"
|
12
|
+
],
|
13
|
+
"default": "normal"
|
14
|
+
},
|
15
|
+
"region": {
|
16
|
+
"title": "DB Engine",
|
17
|
+
"type": "string",
|
18
|
+
"enum": [
|
19
|
+
"",
|
20
|
+
"us-west-1",
|
21
|
+
"us-west-2",
|
22
|
+
"EU",
|
23
|
+
"ap-northeast-1",
|
24
|
+
"ap-southeast-1",
|
25
|
+
"ap-southeast-2"
|
26
|
+
],
|
27
|
+
"default": ""
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'jellyfish_fog_aws/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'jellyfish_fog_aws'
|
7
|
+
s.version = Jellyfish::Fog::AWS::VERSION
|
8
|
+
s.authors = ['Caleb Thompson']
|
9
|
+
s.email = ['caleb@calebthompson.io']
|
10
|
+
s.homepage = 'https://github.com/projectjellyfish/api'
|
11
|
+
s.summary = 'Fog AWS module for Jellyfish Core'
|
12
|
+
s.description = 'Manage AWS products through Fog on Jellyfish Core API'
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
|
18
|
+
s.add_dependency 'rails'
|
19
|
+
s.add_dependency 'fog'
|
20
|
+
s.add_dependency 'bcrypt'
|
21
|
+
|
22
|
+
s.add_development_dependency 'sqlite3'
|
23
|
+
s.add_development_dependency 'rspec-rails'
|
24
|
+
s.add_development_dependency 'shoulda-matchers'
|
25
|
+
s.add_development_dependency 'factory_girl_rails'
|
26
|
+
s.add_development_dependency 'database_cleaner'
|
27
|
+
s.add_development_dependency 'pry-rails'
|
28
|
+
s.add_development_dependency 'custom_configuration'
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fog'
|
2
|
+
require 'bcrypt'
|
3
|
+
require 'jellyfish_fog_aws/engine'
|
4
|
+
require 'jellyfish_fog_aws/databases'
|
5
|
+
require 'jellyfish_fog_aws/storage'
|
6
|
+
require 'jellyfish_fog_aws/infrastructure'
|
7
|
+
|
8
|
+
module Jellyfish
|
9
|
+
module Fog
|
10
|
+
module AWS
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'bcrypt'
|
2
|
+
|
3
|
+
module Jellyfish
|
4
|
+
module Fog
|
5
|
+
module AWS
|
6
|
+
class Databases < ::Provisioner
|
7
|
+
def provision
|
8
|
+
@password = SecureRandom.hex(5)
|
9
|
+
db_instance_id = "id-#{@order_item.uuid[0..9]}"
|
10
|
+
handle_errors do
|
11
|
+
db = connection.create_db_instance(db_instance_id, details)
|
12
|
+
@order_item.payload_response = db.to_json
|
13
|
+
@order_item.provision_status = 'ok'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def retire
|
18
|
+
connection.delete_db_instance(identifier, snapshot, false)
|
19
|
+
@order_item.provision_status = 'retired'
|
20
|
+
rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
|
21
|
+
raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def details
|
27
|
+
@order_item.answers.merge(
|
28
|
+
'MasterUserPassword' => @password,
|
29
|
+
'MasterUsername' => 'admin'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def connection
|
34
|
+
::Fog::AWS::RDS.new(
|
35
|
+
aws_access_key_id: aws_settings.fetch(:access_key),
|
36
|
+
aws_secret_access_key: aws_settings.fetch(:secret_key)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def identifier
|
41
|
+
@order_item.payload_response['data']['body']['CreateDBInstanceResult']['DBInstance']['DBInstanceIdentifier']
|
42
|
+
end
|
43
|
+
|
44
|
+
def snapshot
|
45
|
+
"snapshot-#{@order_item.uuid[0..5]}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def handle_errors
|
49
|
+
yield
|
50
|
+
rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
|
51
|
+
raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|