cloudformer 0.0.2 → 0.0.4
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 +4 -4
- data/README.md +191 -4
- data/cloudformer.gemspec +3 -3
- data/lib/cloudformer.rb +2 -0
- data/lib/cloudformer/stack.rb +2 -0
- data/lib/cloudformer/tasks.rb +5 -2
- data/lib/cloudformer/version.rb +1 -1
- data/samples/Rakefile +7 -0
- data/samples/basic_template.json +31 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94350b9dae02e195dd7365c19ea0a56dd9d155bb
|
4
|
+
data.tar.gz: a08fcc2c9193334db2a83070d9229bfff28abf03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12bdb0def1957cc75ee4161ebd2ecd4b294d38f3096d62b42f2a6ef2a7a48bb1598231ef86dac8342c36a4b746dd354bf461c4a070e913c32a2529f4f09b5f5c
|
7
|
+
data.tar.gz: 5fea38a3eb4390137f2a0cb3214b03fe9c58e9f1d4668bdeea32db7959def4b3f915f41c95c670cddb4e85a6b9d4af4aeecba54941aa108f088976f5a96c454b
|
data/README.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
-
#
|
1
|
+
# CloudFormer
|
2
|
+
|
3
|
+
Cloudformer attempts to simplify AWS Cloudformation stack creation process in ruby projects by providing reusable rake tasks to perform common operations such as apply(create/update), delete, recreate on stack along with validations on templates. Task executions which enforce a stack change will wait until ROLLBACK/COMPLETE or DELETE is signalled on the stack (useful in continuous deployment environments to wait until deployment is successful). Refer [examples section](#example) for more information.
|
4
|
+
|
5
|
+
The list of rake tasks provided are:
|
6
|
+
|
7
|
+
```
|
8
|
+
|
9
|
+
rake apply # Apply Stack with Cloudformation script and parameters(And wait till complete - supports updates)
|
10
|
+
rake delete # Delete stack from CloudFormation(And wait till stack is complete)
|
11
|
+
rake events # Get the recent events from the stack
|
12
|
+
rake outputs # Get the outputs of stack
|
13
|
+
rake recreate # Recreate stack(runs delete & apply)
|
14
|
+
rake status # Get the deployed app status
|
15
|
+
|
16
|
+
```
|
2
17
|
|
3
|
-
TODO: Write a gem description
|
4
18
|
|
5
19
|
## Installation
|
6
20
|
|
@@ -16,9 +30,182 @@ Or install it yourself as:
|
|
16
30
|
|
17
31
|
$ gem install cloudformer
|
18
32
|
|
19
|
-
##
|
33
|
+
## AWS Environment configuration
|
34
|
+
|
35
|
+
Cloudformer depends on the aws-sdk gem to query AWS API. You will need to export AWS configuration to environment variables to your .bashrc/.bash_profile or your build server:
|
36
|
+
|
37
|
+
export AWS_ACCESS_KEY=your access key
|
38
|
+
export AWS_REGION=ap-southeast-2
|
39
|
+
export AWS_SECRET_ACCESS_KEY=your secret access key
|
40
|
+
|
41
|
+
|
42
|
+
## Configuration
|
43
|
+
|
44
|
+
You can add cloudformer tasks to your project by adding the following to your rake file:
|
45
|
+
|
46
|
+
require 'cloudformer'
|
47
|
+
Cloudformer::Tasks.new("earmark") do |t|
|
48
|
+
t.template = "cloudformation/cloudformation.json"
|
49
|
+
t.parameters = parameters
|
50
|
+
end
|
51
|
+
|
52
|
+
where `cloudformation/cloudformation.json` is the stack json file and parameters is a hash of parameters used in the template.
|
53
|
+
For a template which takes the following parameters:
|
54
|
+
|
55
|
+
"Parameters": {
|
56
|
+
"PackageUrl": {
|
57
|
+
"Type": "String"
|
58
|
+
},
|
59
|
+
"PackageVersion": {
|
60
|
+
"Type": "String"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
the parameter hash(Ruby Object) would look like:
|
65
|
+
|
66
|
+
{
|
67
|
+
"PackageUrl" => "http://localhost/app.rpm",
|
68
|
+
"PackageVersion" => "123"
|
69
|
+
}
|
70
|
+
|
71
|
+
If you have a template with no parameters, pass an empty hash `{}` instead.
|
72
|
+
|
73
|
+
## Example
|
74
|
+
|
75
|
+
Here is a simple Cloudformation Stack(Code available in the samples directory) with a Single EC2 Server:
|
76
|
+
|
77
|
+
{
|
78
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
79
|
+
"Description": "Cloudformer - Demo App",
|
80
|
+
"Parameters": {
|
81
|
+
"AmiId": {
|
82
|
+
"Type": "String"
|
83
|
+
}
|
84
|
+
},
|
85
|
+
"Resources": {
|
86
|
+
"ApplicationServer": {
|
87
|
+
"Type": "AWS::EC2::Instance",
|
88
|
+
"Properties": {
|
89
|
+
"ImageId": {
|
90
|
+
"Ref": "AmiId"
|
91
|
+
},
|
92
|
+
"InstanceType": "t1.micro",
|
93
|
+
"Monitoring": "false"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
},
|
97
|
+
"Outputs": {
|
98
|
+
"Server": {
|
99
|
+
"Value": {
|
100
|
+
"Fn::GetAtt": [
|
101
|
+
"ApplicationServer",
|
102
|
+
"PrivateIp"
|
103
|
+
]
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
Then, in your Rakefile add,
|
110
|
+
|
111
|
+
require 'cloudformer/tasks'
|
112
|
+
|
113
|
+
Cloudformer::Tasks.new("app") do |t|
|
114
|
+
t.template = "basic_template.json"
|
115
|
+
#AMI Works in Sydney region only, ensure you supply the right AMI.
|
116
|
+
t.parameters = {"AmiId" => "ami-8da439b7"}
|
117
|
+
end
|
118
|
+
|
119
|
+
You should then see following commands:
|
120
|
+
|
121
|
+
rake apply # Apply Stack with Cloudformation script and parameters
|
122
|
+
rake delete # Delete stack from CloudFormation
|
123
|
+
rake events # Get the recent events from the stack
|
124
|
+
rake outputs # Get the outputs of stack
|
125
|
+
rake recreate # Recreate stack
|
126
|
+
rake status # Get the deployed app status
|
127
|
+
|
128
|
+
Running `rake status` gives us:
|
129
|
+
|
130
|
+
===============================================
|
131
|
+
app - Not Deployed
|
132
|
+
================================================
|
133
|
+
|
134
|
+
Running `rake apply` will create an environment or update existing depending on the nature of action requested in parameters:
|
135
|
+
|
136
|
+
Initializing stack creation...
|
137
|
+
==================================================================================================
|
138
|
+
2013-10-24 07:55:24 UTC - AWS::CloudFormation::Stack - CREATE_IN_PROGRESS - User Initiated
|
139
|
+
2013-10-24 07:55:36 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS -
|
140
|
+
2013-10-24 07:55:37 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS - Resource creation Initiated
|
141
|
+
2013-10-24 07:56:25 UTC - AWS::EC2::Instance - CREATE_COMPLETE -
|
142
|
+
2013-10-24 07:56:26 UTC - AWS::CloudFormation::Stack - CREATE_COMPLETE -
|
143
|
+
==================================================================================================
|
144
|
+
|
145
|
+
Running `rake apply` again gives us:
|
146
|
+
|
147
|
+
No updates are to be performed.
|
148
|
+
|
149
|
+
To remove the stack `rake delete` gives us:
|
150
|
+
|
151
|
+
==============================================================================================
|
152
|
+
Attempting to delete stack - app
|
153
|
+
==============================================================================================
|
154
|
+
2013-10-24 07:55:24 UTC - AWS::CloudFormation::Stack - CREATE_IN_PROGRESS - User Initiated
|
155
|
+
2013-10-24 07:55:36 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS -
|
156
|
+
2013-10-24 07:55:37 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS - Resource creation Initiated
|
157
|
+
2013-10-24 07:56:25 UTC - AWS::EC2::Instance - CREATE_COMPLETE -
|
158
|
+
2013-10-24 07:56:26 UTC - AWS::CloudFormation::Stack - CREATE_COMPLETE -
|
159
|
+
2013-10-24 07:58:54 UTC - AWS::CloudFormation::Stack - DELETE_IN_PROGRESS - User Initiated
|
160
|
+
2013-10-24 07:58:56 UTC - AWS::EC2::Instance - DELETE_IN_PROGRESS -
|
161
|
+
|
162
|
+
Attempts to delete a non-existing stack will result in:
|
163
|
+
|
164
|
+
==============================================
|
165
|
+
Attempting to delete stack - app
|
166
|
+
==============================================
|
167
|
+
Stack not up.
|
168
|
+
==============================================
|
169
|
+
|
170
|
+
To recreate the stack use `rake recreate`:
|
171
|
+
|
172
|
+
=================================================================================================
|
173
|
+
Attempting to delete stack - app
|
174
|
+
=================================================================================================
|
175
|
+
2013-10-24 08:04:11 UTC - AWS::CloudFormation::Stack - CREATE_IN_PROGRESS - User Initiated
|
176
|
+
2013-10-24 08:04:22 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS -
|
177
|
+
2013-10-24 08:04:23 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS - Resource creation Initiated
|
178
|
+
2013-10-24 08:05:12 UTC - AWS::EC2::Instance - CREATE_COMPLETE -
|
179
|
+
2013-10-24 08:05:13 UTC - AWS::CloudFormation::Stack - CREATE_COMPLETE -
|
180
|
+
2013-10-24 08:05:52 UTC - AWS::CloudFormation::Stack - DELETE_IN_PROGRESS - User Initiated
|
181
|
+
2013-10-24 08:06:02 UTC - AWS::EC2::Instance - DELETE_IN_PROGRESS -
|
182
|
+
Stack deleted successfully.
|
183
|
+
Initializing stack creation...
|
184
|
+
=================================================================================================
|
185
|
+
2013-10-24 08:06:31 UTC - AWS::CloudFormation::Stack - CREATE_IN_PROGRESS - User Initiated
|
186
|
+
2013-10-24 08:06:52 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS -
|
187
|
+
2013-10-24 08:06:54 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS - Resource creation Initiated
|
188
|
+
2013-10-24 08:07:41 UTC - AWS::EC2::Instance - CREATE_COMPLETE -
|
189
|
+
=================================================================================================
|
190
|
+
=================================================================================================
|
191
|
+
Server - - 172.31.3.52
|
192
|
+
=================================================================================================
|
193
|
+
|
194
|
+
To see the stack outputs `rake outputs`:
|
195
|
+
|
196
|
+
==============================
|
197
|
+
Server - - 172.31.3.52
|
198
|
+
==============================
|
20
199
|
|
21
|
-
|
200
|
+
To see recent events on the stack `rake events`:
|
201
|
+
|
202
|
+
==================================================================================================
|
203
|
+
2013-10-24 08:06:31 UTC - AWS::CloudFormation::Stack - CREATE_IN_PROGRESS - User Initiated
|
204
|
+
2013-10-24 08:06:52 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS -
|
205
|
+
2013-10-24 08:06:54 UTC - AWS::EC2::Instance - CREATE_IN_PROGRESS - Resource creation Initiated
|
206
|
+
2013-10-24 08:07:41 UTC - AWS::EC2::Instance - CREATE_COMPLETE -
|
207
|
+
2013-10-24 08:07:43 UTC - AWS::CloudFormation::Stack - CREATE_COMPLETE -
|
208
|
+
==================================================================================================
|
22
209
|
|
23
210
|
## Contributing
|
24
211
|
|
data/cloudformer.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Cloudformer::VERSION
|
9
9
|
spec.authors = ["Arvind Kunday"]
|
10
10
|
spec.email = ["hi@kunday.com"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.homepage = ""
|
11
|
+
spec.description = %q{Cloudformation tasks for apply(create/update), delete, recreate on stack along with validations on templates}
|
12
|
+
spec.summary = %q{Cloudformer attempts to simplify AWS Cloudformation stack creation process in ruby projects by providing reusable rake tasks to perform common operations such as apply(create/update), delete, recreate on stack along with validations on templates.}
|
13
|
+
spec.homepage = "https://github.com/kunday/cloudformer"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/cloudformer.rb
CHANGED
data/lib/cloudformer/stack.rb
CHANGED
data/lib/cloudformer/tasks.rb
CHANGED
@@ -28,14 +28,17 @@ module Cloudformer
|
|
28
28
|
def define_create_task
|
29
29
|
desc "Apply Stack with Cloudformation script and parameters."
|
30
30
|
task :apply do
|
31
|
-
p template
|
32
31
|
@stack.apply(template, parameters)
|
33
32
|
end
|
34
33
|
end
|
35
34
|
def define_delete_task
|
36
35
|
desc "Delete stack from CloudFormation"
|
37
36
|
task :delete do
|
38
|
-
|
37
|
+
begin
|
38
|
+
@stack.delete
|
39
|
+
rescue
|
40
|
+
puts "Stack deleted successfully."
|
41
|
+
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
def define_status_task
|
data/lib/cloudformer/version.rb
CHANGED
data/samples/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
3
|
+
"Description": "Cloudformer - Demo App",
|
4
|
+
"Parameters": {
|
5
|
+
"AmiId": {
|
6
|
+
"Type": "String"
|
7
|
+
}
|
8
|
+
},
|
9
|
+
"Resources": {
|
10
|
+
"ApplicationServer": {
|
11
|
+
"Type": "AWS::EC2::Instance",
|
12
|
+
"Properties": {
|
13
|
+
"ImageId": {
|
14
|
+
"Ref": "AmiId"
|
15
|
+
},
|
16
|
+
"InstanceType": "t1.micro",
|
17
|
+
"Monitoring": "false"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"Outputs": {
|
22
|
+
"Server": {
|
23
|
+
"Value": {
|
24
|
+
"Fn::GetAtt": [
|
25
|
+
"ApplicationServer",
|
26
|
+
"PrivateIp"
|
27
|
+
]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudformer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arvind Kunday
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: Cloudformation tasks for apply(create/update), delete, recreate on stack
|
56
|
+
along with validations on templates
|
56
57
|
email:
|
57
58
|
- hi@kunday.com
|
58
59
|
executables: []
|
@@ -69,7 +70,9 @@ files:
|
|
69
70
|
- lib/cloudformer/stack.rb
|
70
71
|
- lib/cloudformer/tasks.rb
|
71
72
|
- lib/cloudformer/version.rb
|
72
|
-
|
73
|
+
- samples/Rakefile
|
74
|
+
- samples/basic_template.json
|
75
|
+
homepage: https://github.com/kunday/cloudformer
|
73
76
|
licenses:
|
74
77
|
- MIT
|
75
78
|
metadata: {}
|
@@ -92,5 +95,7 @@ rubyforge_project:
|
|
92
95
|
rubygems_version: 2.0.6
|
93
96
|
signing_key:
|
94
97
|
specification_version: 4
|
95
|
-
summary:
|
98
|
+
summary: Cloudformer attempts to simplify AWS Cloudformation stack creation process
|
99
|
+
in ruby projects by providing reusable rake tasks to perform common operations such
|
100
|
+
as apply(create/update), delete, recreate on stack along with validations on templates.
|
96
101
|
test_files: []
|