cloudformation-tool 0.8.2 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloud_formation_tool/cli/main.rb +1 -0
- data/lib/cloud_formation_tool/cli/scale.rb +48 -0
- data/lib/cloud_formation_tool/cli/servers.rb +1 -0
- data/lib/cloud_formation_tool/cloud_formation/stack.rb +3 -0
- data/lib/cloud_formation_tool/cloud_formation.rb +1 -1
- data/lib/cloud_formation_tool/storable.rb +1 -0
- data/lib/cloud_formation_tool/version.rb +1 -1
- data/lib/cloud_formation_tool.rb +8 -4
- metadata +62 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16196dd229f1e0040b4b06190e90da9d72dbef2e33ac545055f08a89b3a20339
|
4
|
+
data.tar.gz: 93bc3913458bd350dea067ccd4c7e4ea6562c760f418f17d7b4d34eb918cf1cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 685f2098bfb4278a779683c65fe35937b23a35e9470519a9f2747a912412b13e5229ef81d86c57489170d7a9b88cbb5cb88b2933746cf1fd75786f67b32725ce
|
7
|
+
data.tar.gz: 33278d66726b92d7a9cec30f54499be8b05ab2eab17b9922e42d212e4f66cafc94aa929d2687482bcc1e6373c51975138501ec35c6c053cb7df35901d90a6a77
|
@@ -36,6 +36,7 @@ module CloudFormationTool
|
|
36
36
|
subcommand 'delete', "Delete an existing stack", Delete
|
37
37
|
subcommand 'servers', 'List stack resources', Servers
|
38
38
|
subcommand 'recycle', 'Recycle servers in an auto scaling group', Recycle
|
39
|
+
subcommand 'scale', 'Set the number of desired servesr in an auto scaling group', Scale
|
39
40
|
subcommand 'output', 'Retrieve output values from the stack', Output
|
40
41
|
end
|
41
42
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module CloudFormationTool
|
2
|
+
module CLI
|
3
|
+
|
4
|
+
class Scale < Clamp::Command
|
5
|
+
include CloudFormationTool
|
6
|
+
|
7
|
+
parameter "STACK_NAME", "Name of the stack to recycle servers in"
|
8
|
+
parameter "ASG_NAME", "Name of the auto scaling group in which to recycle all servers"
|
9
|
+
parameter "SCALE", "Number of servers desired"
|
10
|
+
|
11
|
+
def grpstate(grp)
|
12
|
+
grp.instances.collect { |i| i.lifecycle_state }.reduce({}) { |m,s| m[s] = (m[s] || 0) + 1; m }
|
13
|
+
end
|
14
|
+
|
15
|
+
def grpstatedesc(grp)
|
16
|
+
grpstate(grp).collect{|s,c|"#{c} #{s}"}.join(", ")
|
17
|
+
end
|
18
|
+
|
19
|
+
def stable_scale(grp, scale)
|
20
|
+
state = grpstate(grp)
|
21
|
+
state["InService"].eql? scale.to_i and state.delete_if{|k|k.eql? "InService"}.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
#log "Starting scale operations"
|
26
|
+
st = CloudFormation::Stack.new(stack_name)
|
27
|
+
st.asgroups.select do |res|
|
28
|
+
#log "Checking group #{res.logical_resource_id}"
|
29
|
+
asg_name.nil? or (res.logical_resource_id == asg_name)
|
30
|
+
end.collect do |res|
|
31
|
+
#log "Scaling #{res.logical_resource_id}"
|
32
|
+
Thread.new do
|
33
|
+
grp = res.group
|
34
|
+
#log "Current capacity: #{grp.desired_capacity}, setting to #{scale}"
|
35
|
+
grp.set_desired_capacity(desired_capacity: scale)
|
36
|
+
last_state = nil
|
37
|
+
until stable_scale(grp, scale)
|
38
|
+
log "Current scaling status: #{last_state = grpstatedesc(grp)}" unless last_state.eql? grpstatedesc(grp)
|
39
|
+
sleep 3
|
40
|
+
grp.reload
|
41
|
+
end
|
42
|
+
log "Done updating - current scale: #{grpstatedesc(grp)}"
|
43
|
+
end
|
44
|
+
end.each(&:join)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -172,7 +172,7 @@ module CloudFormationTool
|
|
172
172
|
elsif (key == "Code") and (val["Path"])
|
173
173
|
path = resolveVal(val["Path"])
|
174
174
|
if path.is_a? String # resolving works
|
175
|
-
LambdaCode.new(path: "#{@basedir}/#{path}").to_cloudformation
|
175
|
+
LambdaCode.new(path: if path.start_with? "/" then path else "#{@basedir}/#{path}" end).to_cloudformation
|
176
176
|
else # resolving didn't work - we probably don't have parameters
|
177
177
|
val
|
178
178
|
end
|
data/lib/cloud_formation_tool.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'autoloaded'
|
3
|
-
|
3
|
+
|
4
4
|
|
5
5
|
def log(message = nil, &block)
|
6
6
|
($__logger ||= Logger.new(STDERR)).info(if message.nil?
|
@@ -35,6 +35,7 @@ module CloudFormationTool
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def awscreds
|
38
|
+
require 'aws-sdk-core'
|
38
39
|
$__aws_creds ||= Aws::SharedCredentials.new(profile_name: profile)
|
39
40
|
end
|
40
41
|
|
@@ -47,19 +48,23 @@ module CloudFormationTool
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def awsec2
|
51
|
+
require 'aws-sdk-ec2'
|
50
52
|
$__aws_ec2 ||= Aws::EC2::Client.new aws_config
|
51
53
|
end
|
52
54
|
|
53
55
|
def awss3(s3reg = nil)
|
56
|
+
require 'aws-sdk-s3'
|
54
57
|
s3reg ||= region
|
55
58
|
($__aws_s3 ||= {})[region] ||= Aws::S3::Client.new aws_config.merge(region: s3reg)
|
56
59
|
end
|
57
60
|
|
58
61
|
def awscf
|
62
|
+
require 'aws-sdk-cloudformation'
|
59
63
|
$__aws_cf ||= Aws::CloudFormation::Client.new aws_config
|
60
64
|
end
|
61
65
|
|
62
66
|
def awsas
|
67
|
+
require 'aws-sdk-autoscaling'
|
63
68
|
$__aws_as ||= Aws::AutoScaling::Client.new aws_config
|
64
69
|
end
|
65
70
|
|
@@ -76,9 +81,8 @@ module CloudFormationTool
|
|
76
81
|
log("Creating CF template bucket #{name}")
|
77
82
|
awss3.create_bucket({
|
78
83
|
acl: "private",
|
79
|
-
bucket: name
|
80
|
-
|
81
|
-
})
|
84
|
+
bucket: name
|
85
|
+
}.merge(if region == 'us-east-1' then {} else { create_bucket_configuration: { location_constraint: region } } end))
|
82
86
|
name
|
83
87
|
else
|
84
88
|
bucket[:name]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudformation-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Arbel
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2011-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '12'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: clamp
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,19 +39,61 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-sdk
|
42
|
+
name: aws-sdk-cloudformation
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '1'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk-s3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk-ec2
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aws-sdk-autoscaling
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1'
|
41
97
|
- !ruby/object:Gem::Dependency
|
42
98
|
name: autoloaded
|
43
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +145,7 @@ files:
|
|
89
145
|
- lib/cloud_formation_tool/cli/output.rb
|
90
146
|
- lib/cloud_formation_tool/cli/parameters.rb
|
91
147
|
- lib/cloud_formation_tool/cli/recycle.rb
|
148
|
+
- lib/cloud_formation_tool/cli/scale.rb
|
92
149
|
- lib/cloud_formation_tool/cli/servers.rb
|
93
150
|
- lib/cloud_formation_tool/cli/status.rb
|
94
151
|
- lib/cloud_formation_tool/cloud_formation.rb
|
@@ -118,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
175
|
version: '0'
|
119
176
|
requirements: []
|
120
177
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.7.
|
178
|
+
rubygems_version: 2.7.6
|
122
179
|
signing_key:
|
123
180
|
specification_version: 4
|
124
181
|
summary: A pre-compiler tool for CloudFormation YAML templates
|