aws-must 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -17
- data/bin/aws-must.rb +33 -4
- data/demo/4/conf.yaml +2 -2
- data/demo/8/conf.yaml +61 -0
- data/demo/8/mappings.mustache +67 -0
- data/demo/8/output.mustache +40 -0
- data/demo/8/parameter.mustache +38 -0
- data/demo/8/resource.mustache +38 -0
- data/demo/8/resourceInstance.mustache +50 -0
- data/demo/8/resourceInstanceChef.mustache +48 -0
- data/demo/8/resourceSecurityGroup.mustache +37 -0
- data/demo/8/resources.mustache +35 -0
- data/demo/8/root.mustache +160 -0
- data/demo/8/tag.mustache +30 -0
- data/lib/aws-must/aws-must.rb +4 -1
- data/lib/tasks/demo.rake +9 -5
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83a3b8fd5dea520c1d5531c6346279f428945533
|
4
|
+
data.tar.gz: ff8eb51f3a9c3f0e07eb77356c58e3693ef03136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5cbb6189e5aa14f9cbc8e136ea0603e0a33919729edcbbe8705a9a0924a9a58e046b7cb1730be854b4f8d89ae82878994593a2b647408d52e2bcbc598042301
|
7
|
+
data.tar.gz: 7bf6fb2a8410596e44a0619d7e3a2baa938d36800c66a92d1a2ba0d3da0ec5b608680011a29502f2a320ef87ad522a5c410cf11652fa572d574d8c7afde9a98a
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# aws-must - Minimum Viable Solution to Manage CloudFormation Templates - $Release:0.0.
|
1
|
+
# aws-must - Minimum Viable Solution to Manage CloudFormation Templates - $Release:0.0.4$
|
2
2
|
|
3
3
|
`aws-must` is a tool, which allows separating infrastructure
|
4
|
-
configuration and Amazon related syntax
|
5
|
-
[YAML](http://learnxinyminutes.com/docs/yaml) and
|
6
|
-
[Mustache templates](https://mustache.github.io/).
|
4
|
+
configuration and Amazon related syntax in CloudFormation JSON
|
5
|
+
templates using [YAML](http://learnxinyminutes.com/docs/yaml) and
|
6
|
+
[Mustache templates](https://mustache.github.io/).
|
7
7
|
|
8
8
|
|
9
9
|
## The Problem
|
@@ -89,9 +89,9 @@ template `./mustache/root.mustache` issue the command
|
|
89
89
|
|
90
90
|
aws-must.rb gen yaml_file
|
91
91
|
|
92
|
-
To extract documentation between **++start++**
|
93
|
-
**++close++** -tags
|
94
|
-
`./mustache/root.mustache
|
92
|
+
To extract documentation between **++start++** and
|
93
|
+
**++close++** -tags starting with template
|
94
|
+
`./mustache/root.mustache`, issue the command
|
95
95
|
|
96
96
|
aws-must.rb doc
|
97
97
|
|
@@ -148,19 +148,15 @@ line argument `browser`, e.g. `rake demo:html-3[chromium-browser]`.
|
|
148
148
|
|
149
149
|
#### Use Demo to Bootstrap Own Configuration
|
150
150
|
|
151
|
-
To create a copy templates and YAML configuration for demo case
|
152
|
-
run rake task `demo:bootstrap-i
|
153
|
-
|
154
|
-
|
155
|
-
configurations to `tmp/conf`, run
|
151
|
+
To create a copy of templates and YAML configuration for demo case
|
152
|
+
`i`, run rake task `demo:bootstrap-i`, and pass template and
|
153
|
+
configuration directories as command line arguments. For example, to
|
154
|
+
copy demo case `3` templates to directory `tmp/tmpl`, and
|
155
|
+
configurations to directory `tmp/conf`, run
|
156
156
|
|
157
157
|
rake demo:bootstrap-3[tmp/tmpl,tmp/conf]
|
158
158
|
|
159
159
|
|
160
|
-
After this command `tmp/tmpl` contains `root.mustache`, which is the
|
161
|
-
starting point of mustache template rendering, and `tmp/conf` contains
|
162
|
-
a YAML file `conf.yaml` for demo configuration data.
|
163
|
-
|
164
160
|
|
165
161
|
#### Demo Usage on Amazon platform
|
166
162
|
|
@@ -220,10 +216,15 @@ To delete `demo` stack
|
|
220
216
|
|
221
217
|
rake demo:stack-delete
|
222
218
|
|
223
|
-
|
224
219
|
|
220
|
+
## Development
|
221
|
+
|
222
|
+
See [RELEASES](RELEASES.md)
|
223
|
+
|
225
224
|
|
225
|
+
## License
|
226
226
|
|
227
|
+
MIT
|
227
228
|
|
228
229
|
|
229
230
|
|
data/bin/aws-must.rb
CHANGED
@@ -44,19 +44,48 @@ LONGDESC
|
|
44
44
|
# ------------------------------------------------------------------
|
45
45
|
# action 'json'
|
46
46
|
|
47
|
-
desc "json <yaml_file>", "Dump configuration in JSON format"
|
47
|
+
desc "json <yaml_file> [with_adjust]", "Dump configuration in JSON format (with or without adjustment)"
|
48
48
|
|
49
49
|
long_desc <<-LONGDESC
|
50
50
|
|
51
|
-
Reads <yaml_file> and dumps it to stdout in JSON format
|
51
|
+
Reads <yaml_file> and dumps it to stdout in JSON format
|
52
|
+
'with_adjust' (yes/no)
|
53
|
+
|
54
|
+
By default 'adjusts' data, i.e. adds property "_comma" with the
|
55
|
+
value "," to each sub document expect the last one in an array.
|
56
|
+
|
57
|
+
The "_comma" -property helps in generating valid json arrays in
|
58
|
+
mustache templates. For example, YAML construct
|
59
|
+
|
60
|
+
tags:
|
61
|
+
- Key: key1
|
62
|
+
Value: value1
|
63
|
+
|
64
|
+
- Key: key2
|
65
|
+
Value: value2
|
66
|
+
|
67
|
+
and Mustache template snippet
|
68
|
+
|
69
|
+
{ "Tags" : [
|
70
|
+
{{#tags}}
|
71
|
+
{ "Key" : "{{Key}}", "Value" : "{{Value}}"{{_comma}} }
|
72
|
+
{{/tags}}
|
73
|
+
]}
|
74
|
+
|
75
|
+
results to valid JSON document
|
76
|
+
|
77
|
+
{ "Tags" : [
|
78
|
+
{ "Key" : "key1", "Value" : "value1",
|
79
|
+
{ "Key" : "key2", "Value" : "value2"
|
80
|
+
]}
|
52
81
|
|
53
82
|
LONGDESC
|
54
83
|
|
55
84
|
|
56
|
-
def json( yaml_file )
|
85
|
+
def json( yaml_file, with_adjust="true" )
|
57
86
|
|
58
87
|
app = ::AwsMust::AwsMust.new( options )
|
59
|
-
app.json( yaml_file )
|
88
|
+
app.json( yaml_file, with_adjust =~ /^true$/ || with_adjust =~ /^yes$/ ? true : false )
|
60
89
|
|
61
90
|
end
|
62
91
|
|
data/demo/4/conf.yaml
CHANGED
data/demo/8/conf.yaml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
-- demo/2 : added description property
|
2
|
+
|
3
|
+
|
4
|
+
description: "demo/8 - A simple Amazon EC2 instance created using aws-must tool
|
5
|
+
- Minimum Viable Solution to Manage CloudFormation
|
6
|
+
Templates. Adds support installing Chef"
|
7
|
+
|
8
|
+
parameters:
|
9
|
+
|
10
|
+
- Name: InstanceType
|
11
|
+
Type: String
|
12
|
+
Description: EC2 reousrce instance type
|
13
|
+
Value: &Param_InstanceType t2.micro
|
14
|
+
|
15
|
+
- Name: &Param_KeyName KeyName
|
16
|
+
Type: "AWS::EC2::KeyPair::KeyName"
|
17
|
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
18
|
+
Value: demo-key
|
19
|
+
|
20
|
+
- Name: &Param_SSHLocation SSHLocation
|
21
|
+
Type: String
|
22
|
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
23
|
+
Value: "0.0.0.0/0"
|
24
|
+
|
25
|
+
- Name: ChefVersion
|
26
|
+
Type: String
|
27
|
+
Description: Chef version to install
|
28
|
+
Value: &Param_ChefVersion 11.18
|
29
|
+
|
30
|
+
|
31
|
+
resources:
|
32
|
+
|
33
|
+
- InstanceSecurityGroup:
|
34
|
+
Name: &DefaultSG MyDefaultSecurityGroup
|
35
|
+
IngressRef: *Param_SSHLocation
|
36
|
+
|
37
|
+
- Instance:
|
38
|
+
Name: &Resource_1 MyEC2Instance
|
39
|
+
InstanceType: *Param_InstanceType
|
40
|
+
KeyName: *Param_KeyName
|
41
|
+
SecurityGroup: *DefaultSG
|
42
|
+
InstallChef:
|
43
|
+
- Version: *Param_ChefVersion
|
44
|
+
tags:
|
45
|
+
- Key: demotag1
|
46
|
+
Value: demotag1 value
|
47
|
+
|
48
|
+
|
49
|
+
outputs:
|
50
|
+
|
51
|
+
- Name: Instance1
|
52
|
+
Description: InstanceId of the newly created EC2 instance
|
53
|
+
Ref: *Resource_1
|
54
|
+
|
55
|
+
|
56
|
+
- Name: IP1
|
57
|
+
Description: Public IP address of the newly created EC2 instance
|
58
|
+
Attr:
|
59
|
+
Ref: *Resource_1
|
60
|
+
Name: PublicIp
|
61
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
++start++
|
4
|
+
|
5
|
+
## <a id="mappings.mustache"></a>mappings.mustache <a class='navigator' href='#top'">[top]</a>
|
6
|
+
|
7
|
+
|
8
|
+
Create fixed lookup tables `AWSInstanceType2Arch` and
|
9
|
+
`AWSRegionArch2AMI` implementing the table below
|
10
|
+
|
11
|
+
<code><pre>
|
12
|
+
ap-northeast-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-90815290 hvm
|
13
|
+
ap-southeast-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-0accf458 hvm
|
14
|
+
ap-southeast-2 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-1dc8b127 hvm
|
15
|
+
cn-north-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-eae27fd3 hvm
|
16
|
+
eu-central-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-3248712f hvm
|
17
|
+
eu-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-d74437a0 hvm
|
18
|
+
sa-east-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-0f6ced12 hvm
|
19
|
+
us-east-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-83c525e8 hvm
|
20
|
+
us-gov-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-51513172 hvm
|
21
|
+
us-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-61b25925 hvm
|
22
|
+
us-west-2 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-57e8d767 hvm
|
23
|
+
</pre></code>
|
24
|
+
|
25
|
+
|
26
|
+
**Attributes**: context= `.`
|
27
|
+
|
28
|
+
* none
|
29
|
+
|
30
|
+
|
31
|
+
**Actions**:
|
32
|
+
|
33
|
+
* **AWSInstanceType2Arch**: fixed key/value mapping, currently only
|
34
|
+
**t2.micro** --> **64bit**
|
35
|
+
|
36
|
+
* **AWSRegionArch2AMI**: fixed key/value mapping created, currently
|
37
|
+
architectures only for **64bits**
|
38
|
+
|
39
|
+
|
40
|
+
++close++
|
41
|
+
|
42
|
+
|
43
|
+
==================================================================
|
44
|
+
The template
|
45
|
+
==================================================================
|
46
|
+
|
47
|
+
}}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
"AWSInstanceType2Arch" : {
|
52
|
+
"t2.micro" : { "Arch" : "64" }
|
53
|
+
},
|
54
|
+
"AWSRegionArch2AMI" : {
|
55
|
+
"ap-northeast-1" : { "64" : "ami-90815290" },
|
56
|
+
"ap-southeast-1" : { "64" : "ami-0accf458" },
|
57
|
+
"ap-southeast-2" : { "64" : "ami-1dc8b127" },
|
58
|
+
"cn-north-1" : { "64" : "ami-eae27fd3" },
|
59
|
+
"eu-central-1" : { "64" : "ami-3248712f" },
|
60
|
+
"eu-west-1" : { "64" : "ami-d74437a0" },
|
61
|
+
"sa-east-1" : { "64" : "ami-0f6ced12" },
|
62
|
+
"us-east-1" : { "64" : "ami-83c525e8" },
|
63
|
+
"us-west-1" : { "64" : "ami-61b25925" },
|
64
|
+
"us-gov-west-1" : { "64" : "ami-51513172" },
|
65
|
+
"us-west-2" : { "64" : "ami-57e8d767" }
|
66
|
+
}
|
67
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
## <a id="output.mustache"></a>output.mustache <a class='navigator' href='#top'">[top]</a>
|
7
|
+
|
8
|
+
Create one output entry to CloudFormation JSON output section
|
9
|
+
|
10
|
+
**Attributes**: context= `./outputs`
|
11
|
+
|
12
|
+
* `Name` : of the ouput entry
|
13
|
+
* `Description`: of the output entry
|
14
|
+
* `Ref`: name of refernece
|
15
|
+
* `Attr`
|
16
|
+
* `Ref`: name of attribute reference
|
17
|
+
* `Name`: name of the attribute
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
**Actions**:
|
22
|
+
|
23
|
+
* **Name**: `Name`
|
24
|
+
* **Description**: `Description`
|
25
|
+
* **Value**: **Ref** if `Ref`
|
26
|
+
* **Value**: `Attr.Ref`, `Attr.Name` if `Attr`
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
++close++
|
31
|
+
|
32
|
+
}}
|
33
|
+
|
34
|
+
|
35
|
+
"{{Name}}": {
|
36
|
+
"Description" : "{{Description}}"
|
37
|
+
{{#Ref}}, "Value" : { "Ref" : "{{Ref}}" }{{/Ref}}
|
38
|
+
{{#Attr}}, "Value" : { "Fn::GetAtt" : [ "{{Ref}}", "{{Name}}" ] }{{/Attr}}
|
39
|
+
}{{_comma}}
|
40
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
## <a id="parameter.mustache"></a>parameter.mustache <a class='navigator' href='#top'">[top]</a>
|
7
|
+
|
8
|
+
Create one parameter entry to CloudFormation JSON parameter section
|
9
|
+
|
10
|
+
**Attributes**: context= `./parameters`
|
11
|
+
|
12
|
+
* `Name` : of the ouput entry
|
13
|
+
* `Description`: of the parameter entry
|
14
|
+
* `Type`: The data type of [CloudFormation
|
15
|
+
Parameter](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html),
|
16
|
+
e.g. `String`, `AWS::EC2::KeyPair::KeyName`
|
17
|
+
* `Value`: value of the parameter
|
18
|
+
|
19
|
+
|
20
|
+
**Actions**:
|
21
|
+
|
22
|
+
* **Name**: `Name`
|
23
|
+
* **Description**: `Description`
|
24
|
+
* **Type**: `Type`
|
25
|
+
* **Default**: `Value`
|
26
|
+
|
27
|
+
++close++
|
28
|
+
|
29
|
+
}}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
"{{Name}}": {
|
35
|
+
"Description" : "{{Description}}{{^Description}}No description given{{/Description}}",
|
36
|
+
"Type": "{{Type}}",
|
37
|
+
"Default" : "{{Value}}"
|
38
|
+
}{{_comma}}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
resource.mustache
|
4
|
+
|
5
|
+
++start++
|
6
|
+
|
7
|
+
## <a id="resource.mustache"></a>resource.mustache <a class='navigator' href='#top'">[top]</a>
|
8
|
+
|
9
|
+
|
10
|
+
Dispatches resource sub-type templates based resource Type propertys
|
11
|
+
|
12
|
+
**Attributes**: context= `./resources`
|
13
|
+
|
14
|
+
* `Instance`: sub-document defining an EC instance
|
15
|
+
* `SecurityGroup`: sub-document defining an <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html">AWS::EC2::SecurityGroup</a>
|
16
|
+
|
17
|
+
|
18
|
+
**Actions**:
|
19
|
+
|
20
|
+
* **include** <a href="#resourceInstance.mustache">resourceInstance.mustache</a> **if** `Instance`
|
21
|
+
* **include** <a href="#resourceSecurityGroup.mustache">resourceSecurityGroup.mustache</a> **if** `SecurityGroup`
|
22
|
+
|
23
|
+
|
24
|
+
**Included resources**
|
25
|
+
|
26
|
+
* `resourceInstance`
|
27
|
+
|
28
|
+
> resourceInstance
|
29
|
+
> resourceSecurityGroup.mustache
|
30
|
+
|
31
|
+
++close++
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
}}
|
36
|
+
|
37
|
+
{{# Instance }}{{> resourceInstance}}{{/ Instance }}
|
38
|
+
{{# InstanceSecurityGroup }}{{> resourceSecurityGroup}}{{/ InstanceSecurityGroup }}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
|
7
|
+
## <a id="resourceInstance.mustache"></a>resourceInstance.mustache <a class='navigator' href='#top'">[top]</a>
|
8
|
+
|
9
|
+
Create an EC2 instance
|
10
|
+
|
11
|
+
**Attributes**: context= `./resources/Instance`
|
12
|
+
|
13
|
+
* `Name`: name of the EC2 instance to create
|
14
|
+
* `InstanceType` : The instance type, such as t2.micro.
|
15
|
+
* `tags` : array of tag sub-documents for EC2 instance
|
16
|
+
* `InstallChef`: add UserData to install Chef
|
17
|
+
|
18
|
+
|
19
|
+
**Actions**:
|
20
|
+
|
21
|
+
* **Name**: `Name`
|
22
|
+
* **Type**: 'AWS::EC2::Instance'
|
23
|
+
* **for** `tag` **in** `tags` **include** <a href="#tag.mustache">tag.mustache</a>
|
24
|
+
* **SecurityGroups.Ref**: `SecurityGroup` if `SecurityGroup`
|
25
|
+
* **ImageId**: **AWSRegionArch2AMI**( 'AWS::Region', **AWSInstanceType2Arch**(`InstanceType`))
|
26
|
+
* **KeyName**: `KeyName` if `KeyName`
|
27
|
+
* **include** <a href="#resourceInstanceChef.mustache">resourceInstanceChef.mustache</a> if `InstallChef`
|
28
|
+
|
29
|
+
> tag
|
30
|
+
> resourceInstanceChef
|
31
|
+
|
32
|
+
++close++
|
33
|
+
|
34
|
+
}}
|
35
|
+
|
36
|
+
|
37
|
+
"{{Name}}" : {
|
38
|
+
"Type" : "AWS::EC2::Instance",
|
39
|
+
"Properties" : {
|
40
|
+
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
|
41
|
+
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", "{{InstanceType}}", "Arch" ] } ] }
|
42
|
+
, "InstanceType" : "{{InstanceType}}"
|
43
|
+
, "Tags" : [ {{#tags}}{{>tag}}{{/tags}} ]
|
44
|
+
{{#SecurityGroup}}, "SecurityGroups" : [ { "Ref" : "{{SecurityGroup}}" } ]{{/SecurityGroup}}
|
45
|
+
{{#KeyName}}, "KeyName" : { "Ref" : "{{KeyName}}" }{{/KeyName}}
|
46
|
+
{{#InstallChef }}, "UserData": { {{> resourceInstanceChef }} }{{/ InstallChef }}
|
47
|
+
} {{! Propertites }}
|
48
|
+
|
49
|
+
|
50
|
+
}{{_comma}}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
|
7
|
+
## <a id="resourceInstanceChef.mustache"></a>resourceInstanceChef.mustache<a class='navigator' href='#top'"> [top]</a>
|
8
|
+
|
9
|
+
UserData -script to install Chef
|
10
|
+
|
11
|
+
**Attributes**: context= `./resources/Instance/InstallChef`
|
12
|
+
|
13
|
+
* `Version`: Chef version to install
|
14
|
+
|
15
|
+
**Actions**:
|
16
|
+
|
17
|
+
* /bin/bash
|
18
|
+
* CHEF_VERSION=`Version`
|
19
|
+
* LOG="/tmp/install.log"
|
20
|
+
* `curl -L https://www.chef.io/chef/install.sh | sudo bash -s -- -v $CHEF_VERSION >>$LOG 2>&1`
|
21
|
+
|
22
|
+
|
23
|
+
++close++
|
24
|
+
|
25
|
+
}}
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
"Fn::Base64": { "Fn::Join": [
|
30
|
+
"\n",
|
31
|
+
[
|
32
|
+
"#!/bin/bash",
|
33
|
+
"set -x\n",
|
34
|
+
"set -o pipefail\n",
|
35
|
+
"LOG=/tmp/install.log\n",
|
36
|
+
"function finish() {\n",
|
37
|
+
"echo \"$(date): chef installation finished\" >> $LOG\n",
|
38
|
+
"}\n",
|
39
|
+
"trap finish EXIT\n",
|
40
|
+
"CHEF_VERSION={{Version}}\n",
|
41
|
+
"echo $(date): starting to install chef > $LOG\n",
|
42
|
+
"curl -L https://www.chef.io/chef/install.sh | sudo bash -s -- -v $CHEF_VERSION >>$LOG 2>&1\n",
|
43
|
+
"echo $(date): chef installed successfully >> $LOG\n"
|
44
|
+
]
|
45
|
+
]}
|
46
|
+
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
|
7
|
+
## <a id="resourceSecurityGroup.mustache"></a>resourceSecurityGroup.mustache <a class='navigator' href='#top'">[top]</a>
|
8
|
+
|
9
|
+
Create an EC2 Security Group
|
10
|
+
|
11
|
+
**Attributes**: context= `./resources/InstanceSecurityGroup`
|
12
|
+
|
13
|
+
* `Name` : of the security group
|
14
|
+
* `IngressRef`: A refernce to parameter, which defined CIDR for to inbound traffic (ingress)
|
15
|
+
|
16
|
+
**Actions**:
|
17
|
+
|
18
|
+
* **Name**: `Name`
|
19
|
+
* **Type**: "AWS::EC2::SecurityGroup"
|
20
|
+
* **Properties.SecurityGroupIngress[0].CidrIp**: `IngressRef`
|
21
|
+
|
22
|
+
++close++
|
23
|
+
|
24
|
+
}}
|
25
|
+
|
26
|
+
"{{Name}}" : {
|
27
|
+
"Type" : "AWS::EC2::SecurityGroup",
|
28
|
+
"Properties" : {
|
29
|
+
"GroupDescription" : "Enable SSH access via port 22",
|
30
|
+
"SecurityGroupIngress" : [ {
|
31
|
+
"IpProtocol" : "tcp",
|
32
|
+
"FromPort" : "22",
|
33
|
+
"ToPort" : "22",
|
34
|
+
"CidrIp" : { "Ref" : "{{IngressRef}}"}
|
35
|
+
} ]
|
36
|
+
}
|
37
|
+
}{{_comma}}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
++start++
|
4
|
+
|
5
|
+
## <a id="resources.mustache"></a>resources.mustache <a class='navigator' href='#top'">[top]</a>
|
6
|
+
|
7
|
+
Empty template.
|
8
|
+
|
9
|
+
**Attributes**: context= `.`
|
10
|
+
|
11
|
+
* none
|
12
|
+
|
13
|
+
|
14
|
+
**Actions**:
|
15
|
+
|
16
|
+
* no action (i.e. empty template)
|
17
|
+
|
18
|
+
|
19
|
+
++close++
|
20
|
+
|
21
|
+
|
22
|
+
}}
|
23
|
+
{{!
|
24
|
+
|
25
|
+
Moved to YAML
|
26
|
+
|
27
|
+
"MyEC2Instance" : {
|
28
|
+
"Type" : "AWS::EC2::Instance",
|
29
|
+
"Properties" : {
|
30
|
+
"ImageId" : "ami-00dae61d",
|
31
|
+
"InstanceType" : "t2.micro"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
}}
|
@@ -0,0 +1,160 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
root.mustache: root level template,
|
4
|
+
|
5
|
+
==================================================================
|
6
|
+
STYLE section
|
7
|
+
==================================================================
|
8
|
+
|
9
|
+
++start++
|
10
|
+
<style>
|
11
|
+
h1 {
|
12
|
+
color:blue;
|
13
|
+
font-size: 2.5em;
|
14
|
+
}
|
15
|
+
h2 {
|
16
|
+
color:blue;
|
17
|
+
font-size: 1.5em;
|
18
|
+
}
|
19
|
+
h3 {
|
20
|
+
color:blue;
|
21
|
+
font-size: 1.5em;
|
22
|
+
}
|
23
|
+
.navigator {
|
24
|
+
font-size: 0.5em;
|
25
|
+
}
|
26
|
+
body {
|
27
|
+
background-color: #b0c4de;
|
28
|
+
}
|
29
|
+
</style>
|
30
|
+
|
31
|
+
++close++
|
32
|
+
|
33
|
+
|
34
|
+
==================================================================
|
35
|
+
CONTENT section
|
36
|
+
==================================================================
|
37
|
+
|
38
|
+
++start++
|
39
|
+
|
40
|
+
# <a id="top">aws-must demo 8 templates</a>
|
41
|
+
|
42
|
+
This document is generated automically from `aws-must` -demo
|
43
|
+
templates.
|
44
|
+
|
45
|
+
|
46
|
+
Output contains markdown syntax between
|
47
|
+
**++start++** and
|
48
|
+
**++close++** -tags from the template files. For
|
49
|
+
each template, it
|
50
|
+
|
51
|
+
* gives a general description of the template
|
52
|
+
|
53
|
+
* documents the attribute context e.g. `.` or `./resources/Instance`,
|
54
|
+
and attributes referenced within the template
|
55
|
+
|
56
|
+
* lists template actions, i.e. output from template, or template
|
57
|
+
inclusion
|
58
|
+
|
59
|
+
### Table of contents
|
60
|
+
<ul>
|
61
|
+
|
62
|
+
<li><a href="#root.mustache">root.mustache</a>: root template =
|
63
|
+
starting point of template rendering</li>
|
64
|
+
|
65
|
+
<li><a href="#parameter.mustache">parameter.mustache</a>: create one
|
66
|
+
parameter entry to CloudFormation JSON parameter section</li>
|
67
|
+
|
68
|
+
<li><a href="#mappings.mustache">mappings.mustache</a>matches a key to
|
69
|
+
a corresponding set of named values</li>
|
70
|
+
|
71
|
+
<li>Resources</li>
|
72
|
+
|
73
|
+
<ul>
|
74
|
+
|
75
|
+
<li><a href="#resources.mustache">resources.mustache</a>: fixed
|
76
|
+
resources</li>
|
77
|
+
|
78
|
+
<li><a href="#resource.mustache">resource.mustache</a>: dispatch
|
79
|
+
resource based on resource type</li>
|
80
|
+
|
81
|
+
<ul> <li><a
|
82
|
+
href="#resourceSecurityGroup.mustache">resourceSecurityGroup.mustache.mustache</a>:
|
83
|
+
create an security group for accessing EC2 instances</li>
|
84
|
+
|
85
|
+
<li><a
|
86
|
+
href="#resourceInstance.mustache">resourceInstance.mustache</a>:
|
87
|
+
create an EC2 instance</li>
|
88
|
+
|
89
|
+
<ul><li><a href="#tag.mustache">tag.mustache</a>: add key-value tag property
|
90
|
+
to an</li>
|
91
|
+
|
92
|
+
<li><a href="#resourceInstanceChef.mustache">resourceInstanceChef.mustache</a>: UserData -script to install Chef
|
93
|
+
to an</li><ul>
|
94
|
+
|
95
|
+
</ul></ul></ul></ul>
|
96
|
+
|
97
|
+
<li><a href="#output.mustache">output.mustache</a>: values in
|
98
|
+
response to describe stack calls </li> </ul>
|
99
|
+
|
100
|
+
|
101
|
+
## <a id="root.mustache"></a>root.mustache <a class='navigator' href='#top'">[top]</a>
|
102
|
+
|
103
|
+
Starting point of template rendering.
|
104
|
+
|
105
|
+
**Attributes**: context= `.`
|
106
|
+
|
107
|
+
* `description`: description for the CF template
|
108
|
+
* `parameters`: array of parameter sub-documents for CloudFormation Parameters -section
|
109
|
+
* `resources`: array of resource sub-documents for CloudFormation Resources -section
|
110
|
+
* `outputs`: array of output sub-documents for CloudFormation Outputs -section
|
111
|
+
|
112
|
+
|
113
|
+
**Actions**:
|
114
|
+
|
115
|
+
* **Description**: `description`
|
116
|
+
* **for** `parameter` **in** `parameters` **include** <a href="#parameter.mustache">parameter.mustache</a>
|
117
|
+
* **include** <a href="#mappings.mustache">mappings.mustache</a>
|
118
|
+
* **include** <a href="#resources.mustache">resources.mustache</a>
|
119
|
+
* **for** `resource` **in** `resource` **include** <a href="#resource.mustache">resource.mustache</a>
|
120
|
+
* **for** `output` **in** `outputs` **include** <a href="#output.mustache">output.mustache</a>
|
121
|
+
|
122
|
+
|
123
|
+
> parameter
|
124
|
+
> mappings
|
125
|
+
> resources
|
126
|
+
> resource
|
127
|
+
> output
|
128
|
+
|
129
|
+
|
130
|
+
++close++
|
131
|
+
|
132
|
+
}}
|
133
|
+
|
134
|
+
{
|
135
|
+
"AWSTemplateFormatVersion" : "2010-09-09",
|
136
|
+
|
137
|
+
"Description" : "{{description}}",
|
138
|
+
|
139
|
+
"Parameters" : {
|
140
|
+
{{# parameters }}{{> parameter }}{{/ parameters }}
|
141
|
+
},
|
142
|
+
|
143
|
+
"Mappings" : {
|
144
|
+
{{> mappings }}
|
145
|
+
},
|
146
|
+
|
147
|
+
"Resources" : {
|
148
|
+
|
149
|
+
{{> resources }}
|
150
|
+
{{# resources }}{{> resource }}{{/ resources }}
|
151
|
+
|
152
|
+
},
|
153
|
+
|
154
|
+
"Outputs" : {
|
155
|
+
|
156
|
+
{{# outputs }}{{> output }}{{/ outputs }}
|
157
|
+
|
158
|
+
}
|
159
|
+
|
160
|
+
}
|
data/demo/8/tag.mustache
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
|
4
|
+
++start++
|
5
|
+
|
6
|
+
## <a id="tag.mustache"></a>tag.mustache <a class='navigator' href='#top'">[top]</a>
|
7
|
+
|
8
|
+
One key-value pair in EC2 instance Tags -array
|
9
|
+
|
10
|
+
**Attributes**: context= `./resources/Instance/tags`
|
11
|
+
|
12
|
+
* `Key`: of the tag entry
|
13
|
+
* `Value`: of the tag entry
|
14
|
+
|
15
|
+
**Actions**:
|
16
|
+
|
17
|
+
* **Key**: `Name`
|
18
|
+
* **Value**: `Value`
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
++close++
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
}}
|
27
|
+
|
28
|
+
{ "Key" : "{{Key}}", "Value" : "{{Value}}"{{_comma}} }
|
29
|
+
|
30
|
+
|
data/lib/aws-must/aws-must.rb
CHANGED
@@ -28,13 +28,16 @@ module AwsMust
|
|
28
28
|
# ------------------------------------------------------------------
|
29
29
|
# dump 'yaml_file' as json
|
30
30
|
|
31
|
-
def json( yaml_file )
|
31
|
+
def json( yaml_file, with_adjust=true )
|
32
32
|
|
33
33
|
@logger.debug( "#{__method__}, template_name '#{yaml_file}'" )
|
34
34
|
|
35
35
|
#
|
36
36
|
data = read_yaml_file( yaml_file )
|
37
37
|
|
38
|
+
# adjust optionanlly
|
39
|
+
data = adjust( data ) if with_adjust
|
40
|
+
|
38
41
|
puts data.to_json
|
39
42
|
|
40
43
|
|
data/lib/tasks/demo.rake
CHANGED
@@ -26,8 +26,9 @@ namespace "demo" do |ns|
|
|
26
26
|
{ :id => "3", :desc=>"Use resources.mustache -partial to create EC2 intance", :region=>['eu-central-1'], :ssh => false },
|
27
27
|
{ :id => "4", :desc=>"EC2 instance configuration using YAML-data", :region=>['eu-central-1'], :ssh => false },
|
28
28
|
{ :id => "5", :desc=>"Add 'Outputs' -section with reference to EC2 instance", :region=>['eu-central-1'], :ssh => false },
|
29
|
-
{ :id => "6", :desc=>"Add 'Inputs' and 'Mappings' -sections to parametirize", :region=> all_regions, :ssh =>
|
30
|
-
{ :id => "7", :desc=>"Added support for input parameters, EC2 tags, Instance security group", :region=>all_regions, :ssh =>
|
29
|
+
{ :id => "6", :desc=>"Add 'Inputs' and 'Mappings' -sections to parametirize", :region=> all_regions, :ssh => true },
|
30
|
+
{ :id => "7", :desc=>"Added support for input parameters, EC2 tags, Instance security group", :region=>all_regions, :ssh => true },
|
31
|
+
{ :id => "8", :desc=>"Added support for installing Chef", :region=>all_regions, :ssh => true },
|
31
32
|
|
32
33
|
|
33
34
|
].each do |c|
|
@@ -37,9 +38,12 @@ namespace "demo" do |ns|
|
|
37
38
|
sh "#{cmd} gen -t #{demo_dir}/#{c[:id]} #{demo_dir}/#{c[:id]}/conf.yaml"
|
38
39
|
end
|
39
40
|
|
40
|
-
desc "Output configs in '#{demo_dir}/#{c[:id]}' in JSON
|
41
|
-
task "json-#{c[:id]}" do
|
42
|
-
|
41
|
+
desc "Output configs in '#{demo_dir}/#{c[:id]}' in JSON with/without adjustment (default: yes/no)"
|
42
|
+
task "json-#{c[:id]}", :with_adjust do |t, args|
|
43
|
+
|
44
|
+
args.with_defaults( with_adjust: "yes" )
|
45
|
+
|
46
|
+
sh "#{cmd} json #{demo_dir}/#{c[:id]}/conf.yaml #{args.with_adjust}"
|
43
47
|
end
|
44
48
|
|
45
49
|
desc "Check the difference between version '#{c[:id]}' and :prev (default '#{c[:id].to_i() -1}') "
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-must
|
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
|
- jarjuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mustache
|
@@ -72,6 +72,17 @@ files:
|
|
72
72
|
- demo/7/resources.mustache
|
73
73
|
- demo/7/root.mustache
|
74
74
|
- demo/7/tag.mustache
|
75
|
+
- demo/8/conf.yaml
|
76
|
+
- demo/8/mappings.mustache
|
77
|
+
- demo/8/output.mustache
|
78
|
+
- demo/8/parameter.mustache
|
79
|
+
- demo/8/resource.mustache
|
80
|
+
- demo/8/resourceInstance.mustache
|
81
|
+
- demo/8/resourceInstanceChef.mustache
|
82
|
+
- demo/8/resourceSecurityGroup.mustache
|
83
|
+
- demo/8/resources.mustache
|
84
|
+
- demo/8/root.mustache
|
85
|
+
- demo/8/tag.mustache
|
75
86
|
- lib/aws-must.rb
|
76
87
|
- lib/aws-must/aws-must.rb
|
77
88
|
- lib/aws-must/docu.rb
|