akashi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/akashi.gemspec +27 -0
- data/config/application_enviroment.yml.example +43 -0
- data/config/aws.yml.exapmle +3 -0
- data/lib/akashi/aws.rb +37 -0
- data/lib/akashi/base.rb +50 -0
- data/lib/akashi/ec2/ami.rb +14 -0
- data/lib/akashi/ec2/base.rb +19 -0
- data/lib/akashi/ec2/instance.rb +43 -0
- data/lib/akashi/ec2/key_pair.rb +22 -0
- data/lib/akashi/ec2/monkey_patch.rb +7 -0
- data/lib/akashi/ec2.rb +10 -0
- data/lib/akashi/elb/base.rb +11 -0
- data/lib/akashi/elb/load_balancer.rb +53 -0
- data/lib/akashi/elb/ssl_certificate.rb +44 -0
- data/lib/akashi/elb.rb +8 -0
- data/lib/akashi/rds/base.rb +11 -0
- data/lib/akashi/rds/db_instance.rb +43 -0
- data/lib/akashi/rds/subnet_group.rb +18 -0
- data/lib/akashi/rds.rb +8 -0
- data/lib/akashi/version.rb +3 -0
- data/lib/akashi/vpc/base.rb +6 -0
- data/lib/akashi/vpc/instance.rb +33 -0
- data/lib/akashi/vpc/internet_gateway.rb +20 -0
- data/lib/akashi/vpc/route_table.rb +14 -0
- data/lib/akashi/vpc/security_group/base.rb +47 -0
- data/lib/akashi/vpc/security_group/elb.rb +18 -0
- data/lib/akashi/vpc/security_group/gateway.rb +22 -0
- data/lib/akashi/vpc/security_group/rds.rb +21 -0
- data/lib/akashi/vpc/security_group/web.rb +35 -0
- data/lib/akashi/vpc/security_group.rb +13 -0
- data/lib/akashi/vpc/subnet/base.rb +98 -0
- data/lib/akashi/vpc/subnet/elb.rb +13 -0
- data/lib/akashi/vpc/subnet/gateway.rb +13 -0
- data/lib/akashi/vpc/subnet/rds.rb +13 -0
- data/lib/akashi/vpc/subnet/web.rb +13 -0
- data/lib/akashi/vpc/subnet.rb +13 -0
- data/lib/akashi/vpc.rb +11 -0
- data/lib/akashi.rb +110 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ca4dbff7522ca5b3a2e37ac4f2be92a443e66cb
|
4
|
+
data.tar.gz: 0277b555b90816bc0ba16a64001a6e387b4ed6c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6eb6682215d85eb4e4402823b7ae5bdba322b2c2fcd6cab4f34d1c80ec999046a3d60264de3ad8245b6b00713628375271814ae9a9e2dfb0ba1fbbf65917c2b5
|
7
|
+
data.tar.gz: 134c5f8c3a9122204b06ffaf0bfcfe1c1bebf58d77ca126bfc790f1d36fa8e7600c4c22ce4ad622c3853f1030cc4677b1b18a21370252b643e1e105f99740f89
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
akashi (0.0.1)
|
5
|
+
activesupport
|
6
|
+
aws-sdk
|
7
|
+
hashie
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (4.1.1)
|
13
|
+
i18n (~> 0.6, >= 0.6.9)
|
14
|
+
json (~> 1.7, >= 1.7.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
thread_safe (~> 0.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
aws-sdk (1.43.1)
|
19
|
+
json (~> 1.4)
|
20
|
+
nokogiri (>= 1.4.4)
|
21
|
+
hashie (3.0.0)
|
22
|
+
i18n (0.6.9)
|
23
|
+
json (1.8.1)
|
24
|
+
mini_portile (0.6.0)
|
25
|
+
minitest (5.3.4)
|
26
|
+
nokogiri (1.6.2.1)
|
27
|
+
mini_portile (= 0.6.0)
|
28
|
+
rake (10.3.2)
|
29
|
+
thread_safe (0.3.4)
|
30
|
+
tzinfo (1.2.1)
|
31
|
+
thread_safe (~> 0.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
akashi!
|
38
|
+
bundler (~> 1.3)
|
39
|
+
rake
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 asonas
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Akashi
|
2
|
+
|
3
|
+
Wrapping aws-sdk
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'akashi'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install akashi
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
require "yaml"
|
23
|
+
require "akashi"
|
24
|
+
|
25
|
+
Akashi::Aws.config = YAML.load_file("aws.yml"))
|
26
|
+
|
27
|
+
Akashi.application = application
|
28
|
+
Akashi.environment = environment
|
29
|
+
Akashi.manifest = YAML.load_file("#{Akashi.name(separator: "_")}.yml")
|
30
|
+
|
31
|
+
Akashi.send(action.intern)
|
32
|
+
```
|
33
|
+
|
34
|
+
## Configurations
|
35
|
+
### VPC
|
36
|
+
Cidr block is 10.0.0.0/16.
|
37
|
+
|
38
|
+
### Roles
|
39
|
+
|Role|Cidr block
|
40
|
+
|---|---|
|
41
|
+
|ELB|10.0.0.0/19|
|
42
|
+
|SSH Gateway|10.0.32.0/19|
|
43
|
+
|RDS|10.0.64.0/19|
|
44
|
+
|Web Server|10.0.96.0/19|
|
45
|
+
|
46
|
+
#### Allowed input
|
47
|
+
|Role|Protocol|Port|Source|
|
48
|
+
|---|---|---|---|
|
49
|
+
|ELB|TCP|443|0.0.0.0/0|
|
50
|
+
|SSH Gateway|TCP|9922|0.0.0.0/0|
|
51
|
+
||ICMP|-|0.0.0.0/0|
|
52
|
+
|RDS|TCP|3306|10.0.96.0/19|
|
53
|
+
|Web Server|TCP|80|10.0.0.0/19|
|
54
|
+
||TCP|9922|10.0.32.0/19|
|
55
|
+
||ICMP|-|10.0.32.0/19|
|
56
|
+
|
57
|
+
### Subnets
|
58
|
+
Cidr is 24. Create subnet from cidr block of role each availability zone.
|
59
|
+
Example of ELB: 10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24...
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/akashi.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'akashi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "akashi"
|
8
|
+
spec.version = Akashi::VERSION
|
9
|
+
spec.authors = ["asonas", "int_remain"]
|
10
|
+
spec.email = ["hzw1258@gmail.com", "ponde.ponde.ponde@gmail.com"]
|
11
|
+
spec.description = %q{Wrapping aws-sdk}
|
12
|
+
spec.summary = %q{Wrapping awd-sdk}
|
13
|
+
spec.homepage = "https://github.com/spice-life/akashi"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "activesupport"
|
22
|
+
spec.add_dependency "aws-sdk"
|
23
|
+
spec.add_dependency "hashie"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
ec2:
|
2
|
+
instances:
|
3
|
+
gateway: &instance_for_gateway
|
4
|
+
ami_id:
|
5
|
+
instance_class: m3.medium
|
6
|
+
allocated_storage: 8 # GB
|
7
|
+
web: &instance_for_web
|
8
|
+
ami_id:
|
9
|
+
instance_class: m3.medium
|
10
|
+
allocated_storage: 8 # GB
|
11
|
+
public_key:
|
12
|
+
rds:
|
13
|
+
allocated_storage: 5 # GB
|
14
|
+
instance_class: db.t1.micro
|
15
|
+
multi_az: false
|
16
|
+
availability_zone: ap-northeast-1c
|
17
|
+
engine_version: 5.6.17
|
18
|
+
elb:
|
19
|
+
ssl_certificate:
|
20
|
+
server_certificate:
|
21
|
+
private_key_path:
|
22
|
+
health_check:
|
23
|
+
target: HTTP:80/ping
|
24
|
+
role:
|
25
|
+
elb:
|
26
|
+
internet_connection: true
|
27
|
+
subnets:
|
28
|
+
- availability_zone: ap-northeast-1c
|
29
|
+
gateway:
|
30
|
+
internet_connection: true
|
31
|
+
subnets:
|
32
|
+
- availability_zone: ap-northeast-1c
|
33
|
+
instance: *instance_for_gateway
|
34
|
+
number_of_instances: 1
|
35
|
+
rds:
|
36
|
+
subnets:
|
37
|
+
- availability_zone: ap-northeast-1b
|
38
|
+
- availability_zone: ap-northeast-1c
|
39
|
+
web:
|
40
|
+
subnets:
|
41
|
+
- availability_zone: ap-northeast-1c
|
42
|
+
instance: *instance_for_web
|
43
|
+
number_of_instances: 1
|
data/lib/akashi/aws.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module Akashi
|
4
|
+
module Aws
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def config=(new_value)
|
8
|
+
::AWS.config(new_value)
|
9
|
+
services.each { |service| instance_variable_set(:"@#{service}", nil) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def ec2
|
13
|
+
@ec2 ||= ::AWS::EC2.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def elb
|
17
|
+
@elb ||= ::AWS::ELB.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def iam
|
21
|
+
@iam ||= ::AWS::IAM.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def rds
|
25
|
+
@rds ||= ::AWS::RDS.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def services
|
29
|
+
@services ||= [
|
30
|
+
:ec2,
|
31
|
+
:elb,
|
32
|
+
:iam,
|
33
|
+
:rds,
|
34
|
+
]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/akashi/base.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
|
3
|
+
module Akashi
|
4
|
+
class Base
|
5
|
+
extend Forwardable
|
6
|
+
def_delegators :@object, :id
|
7
|
+
|
8
|
+
private_class_method :new
|
9
|
+
|
10
|
+
def initialize(id)
|
11
|
+
@object = self.class.base_class.new(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def all
|
16
|
+
collection.map { |object| new(object.id) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def where(conditions = {})
|
20
|
+
all.select do |instance|
|
21
|
+
conditions.all? { |k, v| instance.send(k.intern) == v }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def find(id)
|
26
|
+
instances = where(id: id)
|
27
|
+
fail "#{id} does not exist" if instances.empty?
|
28
|
+
instances.first
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_by(conditions = {})
|
32
|
+
instances = where(conditions)
|
33
|
+
fail "#{conditions} does not exist" if instances.empty?
|
34
|
+
instances.first
|
35
|
+
end
|
36
|
+
|
37
|
+
def object_class
|
38
|
+
@object_class ||= self.to_s.demodulize
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection
|
42
|
+
Akashi::Aws.send(service_class.underscore).send(object_class.underscore.pluralize)
|
43
|
+
end
|
44
|
+
|
45
|
+
def base_class
|
46
|
+
@base_class ||= "::AWS::#{service_class}::#{object_class}".constantize
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Ec2
|
3
|
+
class Ami < Akashi::Ec2::Base
|
4
|
+
def_delegators :@object, :architecture, :name, :state, :type,
|
5
|
+
:root_device_name, :root_device_type
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def object_class
|
9
|
+
@object_class ||= "Image"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Ec2
|
3
|
+
class Base < Akashi::Base
|
4
|
+
def name=(new_value)
|
5
|
+
@object.add_tag("Name", value: new_value)
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
@object.tags["Name"]
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def service_class
|
14
|
+
@service_class ||= "EC2"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Ec2
|
3
|
+
class Instance < Akashi::Ec2::Base
|
4
|
+
def_delegators :@object, :public_dns_name, :public_ip_address,
|
5
|
+
:private_dns_name, :private_ip_address, :image_id,
|
6
|
+
:key_name, :subnet_id, :vpc_id, :status, :statub_code
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def create(ami:, instance_class:, security_group:, subnet:, allocated_storage:)
|
10
|
+
name = "#{subnet.name}-#{next_number(subnet: subnet)}"
|
11
|
+
|
12
|
+
response = Akashi::Aws.ec2.instances.create(
|
13
|
+
image_id: ami.id,
|
14
|
+
key_name: Akashi.name,
|
15
|
+
security_group_ids: [ security_group.id ],
|
16
|
+
subnet_id: subnet.id,
|
17
|
+
instance_type: instance_class,
|
18
|
+
associate_public_ip_address: true,
|
19
|
+
block_device_mappings: [
|
20
|
+
{
|
21
|
+
device_name: ami.root_device_name,
|
22
|
+
ebs: {
|
23
|
+
volume_size: allocated_storage,
|
24
|
+
delete_on_termination: true,
|
25
|
+
volume_type: "standard",
|
26
|
+
},
|
27
|
+
},
|
28
|
+
],
|
29
|
+
)
|
30
|
+
|
31
|
+
new(response.id).tap do |instance|
|
32
|
+
instance.name = name
|
33
|
+
puts "Created an EC2 Instance (#{instance.id}) on a Subnet (#{subnet.id})."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def next_number(subnet:)
|
38
|
+
"%03d" % (where(subnet_id: subnet.id).count + 1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
module Akashi
|
4
|
+
class Ec2
|
5
|
+
class KeyPair < Akashi::Ec2::Base
|
6
|
+
def_delegators :@object, :fingerprint, :name
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def create
|
10
|
+
response = Akashi::Aws.ec2.client.import_key_pair(
|
11
|
+
key_name: Akashi.name,
|
12
|
+
public_key_material: Base64.encode64(Akashi.manifest.ec2.public_key)
|
13
|
+
)
|
14
|
+
|
15
|
+
new(response[:key_name]).tap do |instance|
|
16
|
+
puts "Created a KeyPair (#{instance.id})."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/akashi/ec2.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Elb
|
3
|
+
class LoadBalancer < Akashi::Elb::Base
|
4
|
+
def_delegators :@object, :dns_name, :name, :subnet_ids, :configure_health_check
|
5
|
+
|
6
|
+
def modify_attributes(options)
|
7
|
+
Akashi::Aws.elb.client.
|
8
|
+
modify_load_balancer_attributes(options.merge({ load_balancer_name: name }))
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def create(security_group:, subnets:, ssl_certificate:)
|
13
|
+
Akashi::Aws.elb.client.create_load_balancer(
|
14
|
+
load_balancer_name: Akashi.name,
|
15
|
+
security_groups: [ security_group.id ],
|
16
|
+
subnets: Array.wrap(subnets).map(&:id),
|
17
|
+
listeners: [
|
18
|
+
{
|
19
|
+
protocol: "HTTPS",
|
20
|
+
load_balancer_port: 443,
|
21
|
+
instance_protocol: "HTTP",
|
22
|
+
instance_port: 80,
|
23
|
+
ssl_certificate_id: ssl_certificate.arn,
|
24
|
+
}
|
25
|
+
],
|
26
|
+
)
|
27
|
+
|
28
|
+
new(Akashi.name).tap do |instance|
|
29
|
+
instance.modify_attributes(
|
30
|
+
load_balancer_attributes: {
|
31
|
+
cross_zone_load_balancing: {
|
32
|
+
enabled: true,
|
33
|
+
},
|
34
|
+
connection_draining: {
|
35
|
+
enabled: true,
|
36
|
+
timeout: 300,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
)
|
40
|
+
instance.configure_health_check(
|
41
|
+
target: Akashi.manifest.elb.health_check.target,
|
42
|
+
interval: 60,
|
43
|
+
timeout: 30,
|
44
|
+
unhealthy_threshold: 2,
|
45
|
+
healthy_threshold: 2,
|
46
|
+
)
|
47
|
+
puts "Created a LoadBalancer(#{instance.name})."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "openssl"
|
2
|
+
|
3
|
+
module Akashi
|
4
|
+
class Elb
|
5
|
+
class SslCertificate < Akashi::Elb::Base
|
6
|
+
def_delegators :@object, :arn, :name, :delete
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def create
|
10
|
+
ssl_certificate = Akashi.manifest.elb.ssl_certificate
|
11
|
+
|
12
|
+
certificate_chain = ssl_certificate.certificate_chain
|
13
|
+
private_key_path = ssl_certificate.private_key_path
|
14
|
+
server_certificate = ssl_certificate.server_certificate
|
15
|
+
|
16
|
+
options = {
|
17
|
+
certificate_body: server_certificate,
|
18
|
+
private_key: OpenSSL::PKey::RSA.new(File.read(private_key_path)).to_pem,
|
19
|
+
server_certificate_name: Akashi.name,
|
20
|
+
}
|
21
|
+
options.merge!({ certificate_chain: certificate_chain }) if !!certificate_chain
|
22
|
+
|
23
|
+
response = Akashi::Aws.iam.client.upload_server_certificate(options)
|
24
|
+
|
25
|
+
new(response[:server_certificate_metadata][:server_certificate_name]).tap do |instance|
|
26
|
+
puts "Created a SSL Certificate (#{instance.name})."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def all
|
31
|
+
collection.map { |object| new(object.name) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def service_class
|
35
|
+
@service_class ||= "IAM"
|
36
|
+
end
|
37
|
+
|
38
|
+
def object_class
|
39
|
+
@object_class ||= "ServerCertificate"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/akashi/elb.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Rds
|
3
|
+
class DbInstance < Akashi::Rds::Base
|
4
|
+
def_delegators :@object, :db_instance_status, :db_name, :endpoint, :endpoint_port,
|
5
|
+
:engine, :engine_version, :vpc_id
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def create(security_group:)
|
9
|
+
password = random_password(10)
|
10
|
+
|
11
|
+
response = Akashi::Aws.rds.client.create_db_instance(
|
12
|
+
db_name: Akashi.name(separator: "_"),
|
13
|
+
db_instance_identifier: Akashi.name,
|
14
|
+
allocated_storage: Akashi.manifest.rds.allocated_storage,
|
15
|
+
db_instance_class: Akashi.manifest.rds.instance_class,
|
16
|
+
engine: "mysql",
|
17
|
+
master_username: Akashi.application,
|
18
|
+
master_user_password: password,
|
19
|
+
multi_az: !!Akashi.manifest.rds.multi_az,
|
20
|
+
availability_zone: Akashi.manifest.rds.availability_zone,
|
21
|
+
vpc_security_group_ids: [ security_group.id ],
|
22
|
+
db_subnet_group_name: Akashi.name,
|
23
|
+
engine_version: Akashi.manifest.rds.engine_version,
|
24
|
+
auto_minor_version_upgrade: true,
|
25
|
+
publicly_accessible: false,
|
26
|
+
)
|
27
|
+
|
28
|
+
new(response[:db_instance_identifier]).tap do |instance|
|
29
|
+
puts "Created a RDS (#{instance.id}). Password is \"#{password}\"."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def random_password(length)
|
34
|
+
[*0..9, *"a".."z", *"A".."Z"].sample(length).join
|
35
|
+
end
|
36
|
+
|
37
|
+
def object_class
|
38
|
+
@object_class ||= "DBInstance"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Akashi
|
2
|
+
class Rds
|
3
|
+
class SubnetGroup
|
4
|
+
class << self
|
5
|
+
def create(subnets:)
|
6
|
+
response = Akashi::Aws.rds.client.create_db_subnet_group(
|
7
|
+
db_subnet_group_name: Akashi.name,
|
8
|
+
db_subnet_group_description: Akashi.name,
|
9
|
+
subnet_ids: Array.wrap(subnets).map(&:id)
|
10
|
+
)
|
11
|
+
id = response[:db_subnet_group_name]
|
12
|
+
|
13
|
+
puts "Created a SubnetGroup (#{id})."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/akashi/rds.rb
ADDED