admiral-cloudformation 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +39 -12
- data/admiral.gemspec +1 -1
- data/examples/elasticsearch/production.json +4 -4
- data/examples/elasticsearch/staging.json +16 -0
- data/examples/meteor/CloudFormation.template +7 -7
- data/examples/meteor/production.json +1 -1
- data/examples/meteor/staging.json +10 -0
- data/examples/mongo/production.json +1 -1
- data/examples/mongo/staging.json +7 -0
- data/lib/admiral-cloudformation/tasks.rb +11 -0
- metadata +5 -2
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Admiral for AWS CloudFormation
|
2
2
|
|
3
|
-
An Admiral module that implements tasks for wielding AWS CloudFormation templates
|
3
|
+
An Admiral module that implements tasks for wielding AWS CloudFormation templates and configuration.
|
4
|
+
|
5
|
+
For additional modules, see the [Admiral base project](https://github.com/flippyhead/admiral).
|
6
|
+
|
7
|
+
Developed in Seattle at [Fetching](http://fetching.io).
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,11 +22,11 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
|
25
|
+
To see a list of available commands, on the command line enter:
|
22
26
|
|
23
27
|
$ admiral cf help
|
24
28
|
|
25
|
-
|
29
|
+
Make sure your bundle bin is in your PATH.
|
26
30
|
|
27
31
|
The following commands are available:
|
28
32
|
|
@@ -31,6 +35,7 @@ Commands:
|
|
31
35
|
admiral cf create # Create new CloudFormation stack for environment.
|
32
36
|
admiral cf destroy # Destroy the existing CloudFormation stack.
|
33
37
|
admiral cf help [COMMAND] # Describe subcommands or one specific subcommand
|
38
|
+
admiral cf init TYPE # Create CloudFormation template and configuration files for TYPE. TYPE is one of "mongo", "meteor", or "elasticsearch"
|
34
39
|
admiral cf update # Update the existing CloudFormation stack
|
35
40
|
|
36
41
|
Options:
|
@@ -43,17 +48,33 @@ Options:
|
|
43
48
|
|
44
49
|
Some commands have additional options you can discover with:
|
45
50
|
|
46
|
-
|
51
|
+
$ admiral cf help [COMMAND]
|
52
|
+
|
53
|
+
## Setup
|
54
|
+
|
55
|
+
It is recommended that you create a distinct repository for each cluster type. For example you might have: `server-elasticsearch`, `server-mongodb`, and `server-meteor` repositories each which specific cluster configurations.
|
56
|
+
|
57
|
+
Within each repo simply run the `init` command to get started (see below).
|
58
|
+
|
59
|
+
## Easy Setup
|
47
60
|
|
48
|
-
|
61
|
+
Admiral CloudFormation provides complete CloudFormation templates for some common server configurations. To initialize your project you can use:
|
49
62
|
|
50
|
-
|
63
|
+
$ admiral cf init <type>
|
64
|
+
|
65
|
+
Where type is one of `mongo`, `elasticsearch` or `meteor`. In the current working directory, this will create a `CloudFormation.template` and `staging.json` and `production.json` files. These are complete configurations using best practices for each server type. You'll need to customize a few things including SSL certificate and security group names.
|
66
|
+
|
67
|
+
More example templates will be added in the future.
|
68
|
+
|
69
|
+
## Configuration
|
70
|
+
|
71
|
+
Admiral CloudFormation is designed around the concept of the deployment `environment`. You parameterize your CloudFormation templates, then encode specific parameter values in JSON files for each distinct environment.
|
51
72
|
|
52
73
|
For example you may have CloudFormation templates for your database servers and your web application servers, and distinct configurations for production, staging and test environments.
|
53
74
|
|
54
75
|
CloudFormation provides a facility to parameterize templates via the [`Parameters`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) section. For example:
|
55
76
|
|
56
|
-
```
|
77
|
+
```json
|
57
78
|
...
|
58
79
|
"InstanceType": {
|
59
80
|
"Description": "The type of instance to launch.",
|
@@ -63,9 +84,9 @@ CloudFormation provides a facility to parameterize templates via the [`Parameter
|
|
63
84
|
...
|
64
85
|
```
|
65
86
|
|
66
|
-
You then specify specific values for each environment. For example:
|
87
|
+
You then specify specific values for each environment. For example, in the `production.json` file:
|
67
88
|
|
68
|
-
```
|
89
|
+
```json
|
69
90
|
{
|
70
91
|
"InstanceCount":"2",
|
71
92
|
"InstanceType": "t2.medium",
|
@@ -84,10 +105,16 @@ Create a stack using the default template (./CloudFormation.template) using a cu
|
|
84
105
|
|
85
106
|
$ admiral cf create --params /usr/local/config/custom.json
|
86
107
|
|
87
|
-
Update the default
|
108
|
+
Update using the default template (./CloudFormation.template) and the default environment config (./production.json):
|
88
109
|
|
89
110
|
$ admiral cf update
|
90
111
|
|
91
|
-
|
112
|
+
## Contributing
|
113
|
+
|
114
|
+
1. Fork it
|
115
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
116
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
117
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
118
|
+
5. Create new Pull Request
|
92
119
|
|
93
|
-
|
120
|
+
This project was heavily inspired by [this blog post](http://www.thoughtworks.com/mingle/news/scaling/2015/01/06/How-Mingle-Built-ElasticSearch-Cluster.html) -- thanks ThoughtWorks!
|
data/admiral.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "admiral-cloudformation"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.4'
|
8
8
|
spec.authors = ["Peter T. Brown"]
|
9
9
|
spec.email = ["p@ptb.io"]
|
10
10
|
spec.description = %q{An Admiral module that implements tasks for wielding AWS CloudFormation templates. Use it to manage CloudFormation templates and their parameters.}
|
@@ -4,13 +4,13 @@
|
|
4
4
|
"SSLCertificateName": "search.example.io",
|
5
5
|
"SshKeyName": "production",
|
6
6
|
"InstanceCount":"2",
|
7
|
-
"InstanceType": "
|
7
|
+
"InstanceType": "c3.large",
|
8
8
|
"ElasticSearchVersion": "1.4.4",
|
9
9
|
"ElasticSearchAWSCloudPluginVersion": "2.4.1",
|
10
10
|
"SearchUser":"admin",
|
11
11
|
"SearchPassword":"example-password",
|
12
|
-
"ClusterName": "
|
12
|
+
"ClusterName": "production-cluster",
|
13
13
|
"MinMasterNodes": "1",
|
14
|
-
"SecurityGroupLoadBalancer": "sg-
|
15
|
-
"SecurityGroupSearchLayer": "sg-
|
14
|
+
"SecurityGroupLoadBalancer": "sg-8aab365abc",
|
15
|
+
"SecurityGroupSearchLayer": "sg-9e9d3abc"
|
16
16
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"Route53ZoneName": "staging.example.io.",
|
3
|
+
"SearchDomainName": "search.staging.example.io",
|
4
|
+
"SSLCertificateName": "search.staging.example.io",
|
5
|
+
"SshKeyName": "staging",
|
6
|
+
"InstanceCount":"2",
|
7
|
+
"InstanceType": "t2.medium",
|
8
|
+
"ElasticSearchVersion": "1.4.4",
|
9
|
+
"ElasticSearchAWSCloudPluginVersion": "2.4.1",
|
10
|
+
"SearchUser":"admin",
|
11
|
+
"SearchPassword":"example-password",
|
12
|
+
"ClusterName": "staging-cluster",
|
13
|
+
"MinMasterNodes": "1",
|
14
|
+
"SecurityGroupLoadBalancer": "sg-8aa123",
|
15
|
+
"SecurityGroupSearchLayer": "sg-9e9123"
|
16
|
+
}
|
@@ -69,13 +69,13 @@
|
|
69
69
|
},
|
70
70
|
|
71
71
|
"PrimaryAppId": {
|
72
|
-
"Description": "
|
73
|
-
"Value": { "Ref": "
|
72
|
+
"Description": "primary app id ",
|
73
|
+
"Value": { "Ref": "PrimaryApp"}
|
74
74
|
},
|
75
75
|
|
76
76
|
"SecondaryAppId": {
|
77
77
|
"Description": "exporter app id ",
|
78
|
-
"Value": { "Ref": "
|
78
|
+
"Value": { "Ref": "SecondaryApp"}
|
79
79
|
}
|
80
80
|
|
81
81
|
},
|
@@ -213,8 +213,8 @@
|
|
213
213
|
"Type":"AWS::OpsWorks::App",
|
214
214
|
"Properties": {
|
215
215
|
"Type": "nodejs",
|
216
|
-
"Name": "
|
217
|
-
"Shortname": "
|
216
|
+
"Name": "Primary Application",
|
217
|
+
"Shortname": "primary-app",
|
218
218
|
"StackId": {
|
219
219
|
"Ref": "MeteorStack"
|
220
220
|
},
|
@@ -231,8 +231,8 @@
|
|
231
231
|
"Type":"AWS::OpsWorks::App",
|
232
232
|
"Properties": {
|
233
233
|
"Type": "nodejs",
|
234
|
-
"Name": "
|
235
|
-
"Shortname": "
|
234
|
+
"Name": "Secondary App",
|
235
|
+
"Shortname": "secondary-app",
|
236
236
|
"StackId": {
|
237
237
|
"Ref": "MeteorStack"
|
238
238
|
},
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"Route53ZoneName": "staging.example.io.",
|
3
|
+
"AppDomainName": "app.staging.example.io",
|
4
|
+
"SSLCertificateName": "app.staging.example.io",
|
5
|
+
"SshKeyName": "staging",
|
6
|
+
"InstanceCount":"1",
|
7
|
+
"InstanceType": "t2.small",
|
8
|
+
"SecurityGroupLoadBalancer": "sg-8ad62234ef",
|
9
|
+
"SecurityGroupMeteorLayer": "sg-2265dsd7"
|
10
|
+
}
|
@@ -9,6 +9,7 @@ module Admiral
|
|
9
9
|
extend Admiral::Base
|
10
10
|
include Util::CloudFormation
|
11
11
|
|
12
|
+
EXAMPLES = ['elasticsearch', 'meteor', 'mongo']
|
12
13
|
NAME = 'cf'
|
13
14
|
USAGE = 'cf <command> <options>'
|
14
15
|
DESCRIPTION = 'Commands for wielding AWS CloudFormation templates.'
|
@@ -45,6 +46,16 @@ module Admiral
|
|
45
46
|
super stack_name options[:environment]
|
46
47
|
end
|
47
48
|
|
49
|
+
desc 'init TYPE', 'Create CloudFormation template and configuration files for TYPE. TYPE is one of "mongo", "meteor", or "elasticsearch"'
|
50
|
+
|
51
|
+
def init(type)
|
52
|
+
raise ArgumentError, "#{type} must be one of #{EXAMPLES.join(',')}" unless EXAMPLES.include?(type)
|
53
|
+
|
54
|
+
path = File.expand_path("../../../examples/#{type}", __FILE__)
|
55
|
+
FileUtils.cp Dir.glob("#{path}/*"), Dir.getwd
|
56
|
+
puts "[admiral] #{type} CloudFormation setup initialized."
|
57
|
+
end
|
58
|
+
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admiral-cloudformation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -108,10 +108,13 @@ files:
|
|
108
108
|
- admiral.gemspec
|
109
109
|
- examples/elasticsearch/CloudFormation.template
|
110
110
|
- examples/elasticsearch/production.json
|
111
|
+
- examples/elasticsearch/staging.json
|
111
112
|
- examples/meteor/CloudFormation.template
|
112
113
|
- examples/meteor/production.json
|
114
|
+
- examples/meteor/staging.json
|
113
115
|
- examples/mongo/CloudFormation.template
|
114
116
|
- examples/mongo/production.json
|
117
|
+
- examples/mongo/staging.json
|
115
118
|
- lib/admiral-cloudformation.rb
|
116
119
|
- lib/admiral-cloudformation/tasks.rb
|
117
120
|
- lib/admiral-cloudformation/util.rb
|