cfnlego 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 +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +65 -0
- data/Guardfile +5 -0
- data/README.md +50 -0
- data/Rakefile +13 -0
- data/bin/cfnlego +36 -0
- data/cfnlego.gemspec +25 -0
- data/lib/cfnlego/cloudformation.erb +20 -0
- data/lib/cfnlego/cloudformation.rb +19 -0
- data/lib/cfnlego/resource.rb +33 -0
- data/lib/cfnlego/resources/AutoScaling/AutoScalingGroup.yaml +44 -0
- data/lib/cfnlego/resources/AutoScaling/LaunchConfiguration.yaml +157 -0
- data/lib/cfnlego/resources/AutoScaling/LifecycleHook.yaml +10 -0
- data/lib/cfnlego/resources/IAM/InstanceProfile.yaml +5 -0
- data/lib/cfnlego/resources/IAM/Role.yaml +27 -0
- data/lib/cfnlego/version.rb +3 -0
- data/lib/cfnlego.rb +7 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d3071c56e1059f475029b66839b65fd41ad0b7d
|
4
|
+
data.tar.gz: f33ffc1462b2b3f8036f2a54b89ce93e77cbe8e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ba6291154bedf8a1173feb774fa4b7f0849795f5fe6d668ed6dbb061e4da7a1ba5788927c4dc74a084871c1e0d6ca2aa145b2a74d0f943d5cc424edd9897b1f
|
7
|
+
data.tar.gz: 5402961bdff6f8f2958624a3791b66cef66d2719c04234011a8bac15a2e3ee9ab1f6dd4a270e550d793f46d7990996ce2a71334844da82160725f5bb29dd0604
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.ruby-gemset
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
cfndsl (0.2.2)
|
5
|
+
coderay (1.1.0)
|
6
|
+
diff-lcs (1.2.5)
|
7
|
+
ffi (1.9.10)
|
8
|
+
formatador (0.2.5)
|
9
|
+
guard (2.13.0)
|
10
|
+
formatador (>= 0.2.4)
|
11
|
+
listen (>= 2.7, <= 4.0)
|
12
|
+
lumberjack (~> 1.0)
|
13
|
+
nenv (~> 0.1)
|
14
|
+
notiffany (~> 0.0)
|
15
|
+
pry (>= 0.9.12)
|
16
|
+
shellany (~> 0.0)
|
17
|
+
thor (>= 0.18.1)
|
18
|
+
guard-compat (1.2.1)
|
19
|
+
guard-rspec (4.6.4)
|
20
|
+
guard (~> 2.1)
|
21
|
+
guard-compat (~> 1.1)
|
22
|
+
rspec (>= 2.99.0, < 4.0)
|
23
|
+
listen (3.0.3)
|
24
|
+
rb-fsevent (>= 0.9.3)
|
25
|
+
rb-inotify (>= 0.9)
|
26
|
+
lumberjack (1.0.9)
|
27
|
+
method_source (0.8.2)
|
28
|
+
nenv (0.2.0)
|
29
|
+
notiffany (0.0.7)
|
30
|
+
nenv (~> 0.1)
|
31
|
+
shellany (~> 0.0)
|
32
|
+
pry (0.10.1)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.8.1)
|
35
|
+
slop (~> 3.4)
|
36
|
+
rake (10.4.2)
|
37
|
+
rb-fsevent (0.9.5)
|
38
|
+
rb-inotify (0.9.5)
|
39
|
+
ffi (>= 0.5.0)
|
40
|
+
rspec (3.3.0)
|
41
|
+
rspec-core (~> 3.3.0)
|
42
|
+
rspec-expectations (~> 3.3.0)
|
43
|
+
rspec-mocks (~> 3.3.0)
|
44
|
+
rspec-core (3.3.2)
|
45
|
+
rspec-support (~> 3.3.0)
|
46
|
+
rspec-expectations (3.3.1)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.3.0)
|
49
|
+
rspec-mocks (3.3.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.3.0)
|
52
|
+
rspec-support (3.3.0)
|
53
|
+
shellany (0.0.1)
|
54
|
+
slop (3.6.0)
|
55
|
+
thor (0.19.1)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
cfndsl
|
62
|
+
guard
|
63
|
+
guard-rspec
|
64
|
+
rake
|
65
|
+
rspec
|
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
cfnlego
|
2
|
+
========
|
3
|
+
|
4
|
+
### description
|
5
|
+
|
6
|
+
cfnlego is built to quickly bootstrap CloudFormation development with cfndsl.
|
7
|
+
|
8
|
+
It provides templates for all AWS Resources and simpliy bake them into a template
|
9
|
+
|
10
|
+
### How to use
|
11
|
+
|
12
|
+
to generate a `cfndsl` template, provide the resource types and their logical names in the command line.
|
13
|
+
|
14
|
+
```sh
|
15
|
+
bundle exec cfnlego --help
|
16
|
+
Usage: cfnlego --reousrce resource [options]
|
17
|
+
-r RESOURCE_TYPE,RESOURCE_LOGICAL_NAME
|
18
|
+
--resource Add resource type and logical name
|
19
|
+
-h, --help Prints this help
|
20
|
+
Example:
|
21
|
+
cfnlego \
|
22
|
+
--reousrce AutoScaling::AutoScalingGroup,ASG \
|
23
|
+
--reousrce IAM::Role,Role \
|
24
|
+
--reousrce IAM::InstanceProfile,InstanceProfile \
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
### License
|
29
|
+
|
30
|
+
The MIT License (MIT)
|
31
|
+
|
32
|
+
Copyright (c) 2015 [Kevin Yung](mailto:me@howareyoukevin.com)
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
35
|
+
of this software and associated documentation files (the "Software"), to deal
|
36
|
+
in the Software without restriction, including without limitation the rights
|
37
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
38
|
+
copies of the Software, and to permit persons to whom the Software is
|
39
|
+
furnished to do so, subject to the following conditions:
|
40
|
+
|
41
|
+
The above copyright notice and this permission notice shall be included in
|
42
|
+
all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
45
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
46
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
47
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
48
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
49
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
50
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/cfnlego
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/cfnlego'
|
3
|
+
require 'optparse'
|
4
|
+
options = {resources: []}
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = "Usage: cfnlego --reousrce resource [options]"
|
7
|
+
|
8
|
+
opts.on("-r", "--resource=RESOURCE_TYPE,RESOURCE_LOGICAL_NAME", "Add resource type and logical name") do |r|
|
9
|
+
options[:resources] << r
|
10
|
+
end
|
11
|
+
|
12
|
+
opts.on("-h", "--help", "Prints this help") do
|
13
|
+
puts opts
|
14
|
+
puts <<-EXAMPLE
|
15
|
+
Example:
|
16
|
+
cfnlego \\
|
17
|
+
--reousrce AutoScaling::AutoScalingGroup,ASG \\
|
18
|
+
--reousrce IAM::Role,Role \\
|
19
|
+
--reousrce IAM::InstanceProfile,InstanceProfile \\
|
20
|
+
EXAMPLE
|
21
|
+
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end.parse!
|
25
|
+
|
26
|
+
# Constructure Resources
|
27
|
+
resources = []
|
28
|
+
options[:resources].each do |r|
|
29
|
+
/(.*),(.*)/.match(r) do |m|
|
30
|
+
type = m[1]
|
31
|
+
name = m[2]
|
32
|
+
resources << Cfnlego::Resource.new(type, name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
puts Cfnlego::CloudFormation.new(resources).render
|
data/cfnlego.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cfnlego/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cfnlego"
|
8
|
+
spec.version = Cfnlego::VERSION
|
9
|
+
spec.authors = ["Kevin Yung"]
|
10
|
+
spec.email = ["me@howareyoukevin.com"]
|
11
|
+
spec.licenses = ["MIT"]
|
12
|
+
|
13
|
+
spec.summary = %q{Command Line tool to bootstrap CloudForamtion development with cfndsl}
|
14
|
+
spec.description = %q{Command line tool to bootstrap CloudFormation development with cfndsl}
|
15
|
+
spec.homepage = "https://github.com/allinwonder/cfnlego"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
spec.bindir = "bin"
|
20
|
+
spec.executables << "cfnlego"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "cfndsl", "~> 0.2"
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
CloudFormation do
|
2
|
+
Description "<%= @description %>"
|
3
|
+
<%- @resources.each do |r| -%>
|
4
|
+
<%="Resource \"#{r.name}\" do" %>
|
5
|
+
<%="Type \"AWS::#{r.type}\"" %>
|
6
|
+
<%- attrs = r.attributes -%>
|
7
|
+
<%- if attrs
|
8
|
+
attrs.keys.each do |attr| -%>
|
9
|
+
<%- attrs[attr].keys.each do |name| -%>
|
10
|
+
<%="#{attr} \"#{name}\", #{attrs[attr][name]}" %>
|
11
|
+
<%- end -%>
|
12
|
+
<%- end-%>
|
13
|
+
<%- end -%>
|
14
|
+
<%- ps = r.properties -%>
|
15
|
+
<%- ps.keys.each do |p| -%>
|
16
|
+
<%="Property \"#{p}\", #{ps[p]}" %>
|
17
|
+
<%- end -%>
|
18
|
+
end
|
19
|
+
<% end -%>
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Cfnlego
|
2
|
+
|
3
|
+
class CloudFormation
|
4
|
+
TEMPLATE="#{File.dirname(__FILE__)}/cloudformation.erb"
|
5
|
+
|
6
|
+
attr_reader :resources
|
7
|
+
|
8
|
+
def initialize(resources)
|
9
|
+
@description = "auto generated cloudformation cfndsl template"
|
10
|
+
@resources = resources
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def render
|
15
|
+
erb = ERB.new(File.read(TEMPLATE), nil, '-')
|
16
|
+
erb.result(binding)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Cfnlego
|
4
|
+
class Resource
|
5
|
+
attr_reader :type, :name
|
6
|
+
|
7
|
+
def initialize(type, name)
|
8
|
+
@type = type
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def attributes
|
13
|
+
definition["AWS::#{@type}"]["Attributes"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def properties
|
17
|
+
definition["AWS::#{@type}"]['Properties']
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# example AutoScaling::AutoScalingGroup
|
23
|
+
def type2file
|
24
|
+
@file ||= "#{File.dirname(__FILE__)}/resources/#{@type.gsub(/::/, "/")}.yaml"
|
25
|
+
end
|
26
|
+
|
27
|
+
def definition
|
28
|
+
@definition ||= YAML.load_file(type2file)
|
29
|
+
rescue
|
30
|
+
$stderr.puts "unknown #{@type}, no matching definition found"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
AWS::AutoScaling::AutoScalingGroup:
|
2
|
+
Attributes:
|
3
|
+
UpdatePolicy:
|
4
|
+
AutoScalingRollingUpdate: |
|
5
|
+
{
|
6
|
+
"MaxBatchSize" => "1",
|
7
|
+
"MinInstancesInService" => "1",
|
8
|
+
"PauseTime" => "300",
|
9
|
+
"SuspendProcesses" => ["Launch", "Terminate", "HealthCheck", "ReplaceUnhealthy", "AZRebalance", "AlarmNotification", "ScheduledActions", "AddToLoadBalancer"],
|
10
|
+
"WaitOnResourceSignals" => true
|
11
|
+
}
|
12
|
+
AutoScalingScheduledAction: |
|
13
|
+
{ "IgnoreUnmodifiedGroupSizeProperties" => true }
|
14
|
+
Properties:
|
15
|
+
AvailabilityZones: ["ap-southeast-2a", "ap-southeast-2b"]
|
16
|
+
Cooldown: "300"
|
17
|
+
DesiredCapacity: "2"
|
18
|
+
HealthCheckGracePeriod: "300"
|
19
|
+
HealthCheckType: "\"ELB\""
|
20
|
+
InstanceId: "\"i-xxxxxx\""
|
21
|
+
LaunchConfigurationName: "\"launchconfig-xxxxxx\"" #Ref("LaunchConfiguration")
|
22
|
+
LoadBalancerNames: |
|
23
|
+
["lb-xxxx"] #[Ref("LoadBalancer")]
|
24
|
+
MaxSize: "2"
|
25
|
+
MetricsCollection: |
|
26
|
+
{
|
27
|
+
"Granularity" => "1Minute",
|
28
|
+
"Metrics" => [] #all metrics will be sent to cloudwatch by default
|
29
|
+
}
|
30
|
+
MinSize: "1"
|
31
|
+
NotificationConfigurations: |
|
32
|
+
[{
|
33
|
+
"NotificationTypes" => [ "autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_LAUNCH_ERROR", "autoscaling:EC2_INSTANCE_TERMINATE", "autoscaling:EC2_INSTANCE_TERMINATE_ERROR", "autoscaling:TEST_NOTIFICATION" ],
|
34
|
+
"TopicARN" => "arn:aws:::xxxx"
|
35
|
+
}]
|
36
|
+
PlacementGroup: "\"placement group name\""
|
37
|
+
Tags: |
|
38
|
+
[{
|
39
|
+
"Key" => "Application",
|
40
|
+
"Value" => "",
|
41
|
+
"PropagateAtLaunch" => true
|
42
|
+
}]
|
43
|
+
TerminationPolicies: ["OldestInstance", "NewestInstance", "OldestLaunchConfiguration", "ClosestToNextInstanceHour", "Default"]
|
44
|
+
VPCZoneIdentifier: ["subnet-xxxx", "subnet-xxxx"]
|
@@ -0,0 +1,157 @@
|
|
1
|
+
AWS::AutoScaling::LaunchConfiguration:
|
2
|
+
Attributes:
|
3
|
+
CreationPolicy:
|
4
|
+
ResourceSignal: |
|
5
|
+
{ "Count" => 2, "Timeout" => "PT15M" }
|
6
|
+
Metadata:
|
7
|
+
AWS::CloudFormation::Init: |
|
8
|
+
{
|
9
|
+
"configSets" => {
|
10
|
+
"ascending" => [ "config1" , "config2" ],
|
11
|
+
"descending" => [ "config2" , "config1" ]
|
12
|
+
},
|
13
|
+
"config1" => {
|
14
|
+
"commands" => {
|
15
|
+
"test" => {
|
16
|
+
"command" => "echo \"$CFNTEST\" > test.txt",
|
17
|
+
"env" => { "CFNTEST" => "I come from config1." },
|
18
|
+
"cwd" => "~"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"config2" => {
|
23
|
+
"packages" => {
|
24
|
+
"rpm" => {
|
25
|
+
"epel" => "http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm"
|
26
|
+
},
|
27
|
+
"yum" => {
|
28
|
+
"httpd" => [],
|
29
|
+
"php" => [],
|
30
|
+
"wordpress" => []
|
31
|
+
},
|
32
|
+
"rubygems" => {
|
33
|
+
"chef" => [ "0.10.2" ]
|
34
|
+
},
|
35
|
+
"msi" => {
|
36
|
+
"awscli" => "https://s3.amazonaws.com/aws-cli/AWSCLI64.msi"
|
37
|
+
}
|
38
|
+
},
|
39
|
+
"groups" => {
|
40
|
+
"groupOne" => {},
|
41
|
+
"groupTwo" => { "gid" => "45" }
|
42
|
+
},
|
43
|
+
"users" => {
|
44
|
+
"myUser" => {
|
45
|
+
"groups" => ["groupOne", "groupTwo"],
|
46
|
+
"uid" => "50",
|
47
|
+
"homeDir" => "/tmp"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"sources" => {
|
51
|
+
"/etc/puppet" => "https://github.com/user1/cfn-demo/tarball/master"
|
52
|
+
},
|
53
|
+
"files" => {
|
54
|
+
"/tmp/myfile2.txt" => {
|
55
|
+
"content" => "/tmp/myfile1.txt",
|
56
|
+
"mode" => "000644",
|
57
|
+
"owner" => "root",
|
58
|
+
"group" => "root"
|
59
|
+
},
|
60
|
+
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" => {
|
61
|
+
"content" => FnJoin("", [
|
62
|
+
"[cfn-auto-reloader-hook]\n",
|
63
|
+
"triggers=post.update\n",
|
64
|
+
"path=Resources.YOUR-RESOURCE-LOGICAL-NAME.Metadata.AWS::CloudFormation::Init\n",
|
65
|
+
"action=/opt/aws/bin/cfn-init -v ",
|
66
|
+
" --stack ", Ref("AWS::StackName"),
|
67
|
+
" --resource WebServer ",
|
68
|
+
" --configsets wordpress_install ",
|
69
|
+
" --region ", Ref("AWS::Region"), "\n"
|
70
|
+
]),
|
71
|
+
"mode" => "000400",
|
72
|
+
"owner" => "root",
|
73
|
+
"group" => "root"
|
74
|
+
}
|
75
|
+
},
|
76
|
+
"commands" => {
|
77
|
+
"test" => {
|
78
|
+
"command" => "echo \"$MAGIC\" > test.txt",
|
79
|
+
"env" => { "MAGIC" => "I come from the environment!" },
|
80
|
+
"cwd" => "~",
|
81
|
+
"test" => "test ! -e ~/test.txt",
|
82
|
+
"ignoreErrors" => "false"
|
83
|
+
}
|
84
|
+
},
|
85
|
+
"services" => {
|
86
|
+
"sysvinit" => {
|
87
|
+
"nginx" => {
|
88
|
+
"enabled" => "true",
|
89
|
+
"ensureRunning" => "true",
|
90
|
+
"files" => ["/etc/nginx/nginx.conf"],
|
91
|
+
"sources" => ["/var/www/html"]
|
92
|
+
},
|
93
|
+
"php-fastcgi" => {
|
94
|
+
"enabled" => "true",
|
95
|
+
"ensureRunning" => "true",
|
96
|
+
"packages" => { "yum" => ["php", "spawn-fcgi"] }
|
97
|
+
},
|
98
|
+
"sendmail" => {
|
99
|
+
"enabled" => "false",
|
100
|
+
"ensureRunning" => "false"
|
101
|
+
}
|
102
|
+
},
|
103
|
+
"windows" => {
|
104
|
+
"cfn-hup" => {
|
105
|
+
"enabled" => "true",
|
106
|
+
"ensureRunning" => "true",
|
107
|
+
"files" => ["c=>\\cfn\\cfn-hup.conf", "c=>\\cfn\\hooks.d\\cfn-auto-reloader.conf"]
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
Properties:
|
114
|
+
AssociatePublicIpAddress: false
|
115
|
+
BlockDeviceMappings: |
|
116
|
+
[{
|
117
|
+
"DeviceName" => "/dev/sdf",
|
118
|
+
"Ebs" => {
|
119
|
+
"DeleteOnTermination" => "false",
|
120
|
+
"Iops" => "1000",
|
121
|
+
"SnapshotId" => "snap-xxxx",
|
122
|
+
"VolumeSize" => "100",
|
123
|
+
"VolumeType" => "standard"
|
124
|
+
},
|
125
|
+
"NoDevice" => "false",
|
126
|
+
"VirtualName" => "ephemeralX"
|
127
|
+
}]
|
128
|
+
ClassicLinkVPCId: "\"vpc-xxxxx\""
|
129
|
+
ClassicLinkVPCSecurityGroups: ["sg-xxx", "sg-xxx"]
|
130
|
+
EbsOptimized: "\"false\""
|
131
|
+
IamInstanceProfile: "\"instance-profile-xxxxxx\"" #Ref("InstanceProfile")
|
132
|
+
ImageId: "\"ami-xxxxx\""
|
133
|
+
InstanceId: "\"i-xxxxxxx\"" # Ref("Instance")
|
134
|
+
InstanceMonitoring: "\"true\""
|
135
|
+
InstanceType: "\"t2.micro\""
|
136
|
+
KernelId: "\"kn-xxx\""
|
137
|
+
KeyName: "\"your-ssh-key\""
|
138
|
+
PlacementTenancy: "\"dedicated - delete me if you are not using dedicated HW\""
|
139
|
+
RamDiskId: "\"ram-xxx\""
|
140
|
+
SecurityGroups: |
|
141
|
+
[ "sg-xxxxxx" ] # [ Ref("SecurityGroup") ]
|
142
|
+
SpotPrice: "\"0.02\""
|
143
|
+
UserData: |
|
144
|
+
FnJoin("", [
|
145
|
+
"#!/bin/bash\n",
|
146
|
+
"# Default UserData for linux\n",
|
147
|
+
"yum update --security\n",
|
148
|
+
"/opt/aws/bin/cfn-init -v ",
|
149
|
+
" --stack ", Ref("AWS::StackName"),
|
150
|
+
" --resource LaunchConfig ",
|
151
|
+
" --configsets default ",
|
152
|
+
" --region ", Ref("AWS::Region"), "\n",
|
153
|
+
"/opt/aws/bin/cfn-signal -e $? ",
|
154
|
+
" --stack ", Ref("AWS::StackName"),
|
155
|
+
" --resource ASG",
|
156
|
+
" --region ", Ref("AWS::Region"), "\n"
|
157
|
+
])
|
@@ -0,0 +1,10 @@
|
|
1
|
+
AWS::AutoScaling::LifecycleHook:
|
2
|
+
Attributes:
|
3
|
+
Properties:
|
4
|
+
AutoScalingGroupName: "\"asg-xxx\"" #Ref("ASG")
|
5
|
+
DefaultResult: "\"CONTINUE or ABANDON\""
|
6
|
+
HeartbeatTimeout: "\"120 (unit is econd)\""
|
7
|
+
LifecycleTransition: "\"autoscaling:EC2_INSTANCE_TERMINATING or autoscaling:EC2_INSTANCE_LAUNCHING\""
|
8
|
+
NotificationMetadata: "\"good to put your application name\""
|
9
|
+
NotificationTargetARN: "\"arn:aws:: - SNS to receive lifecycle hook notification\""
|
10
|
+
RoleARN: "\"arn:aws:iam:... The IAM role that allows the Auto Scaling group to publish to the specified notification target.\""
|
@@ -0,0 +1,27 @@
|
|
1
|
+
AWS::IAM::Role:
|
2
|
+
Properties:
|
3
|
+
AssumeRolePolicyDocument: |
|
4
|
+
{
|
5
|
+
"Version" => "2012-10-17",
|
6
|
+
"Statement" => [ {
|
7
|
+
"Effect" => "Allow",
|
8
|
+
"Principal" => {
|
9
|
+
"Service" => [ "ec2.amazonaws.com" ]
|
10
|
+
},
|
11
|
+
"Action" => [ "sts:AssumeRole" ]
|
12
|
+
} ]
|
13
|
+
}
|
14
|
+
ManagedPolicyArns: []
|
15
|
+
Path: "\"/Application/\""
|
16
|
+
Policies: |
|
17
|
+
[{
|
18
|
+
"PolicyName" => "AllowNothing",
|
19
|
+
"PolicyDocument" => {
|
20
|
+
"Version" => "2012-10-17",
|
21
|
+
"Statement" => [ {
|
22
|
+
"Effect" => "Deny",
|
23
|
+
"Action" => "*",
|
24
|
+
"Resource" => "*"
|
25
|
+
} ]
|
26
|
+
}
|
27
|
+
}]
|
data/lib/cfnlego.rb
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cfnlego
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Yung
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cfndsl
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.2'
|
55
|
+
description: Command line tool to bootstrap CloudFormation development with cfndsl
|
56
|
+
email:
|
57
|
+
- me@howareyoukevin.com
|
58
|
+
executables:
|
59
|
+
- cfnlego
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".ruby-version"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- Guardfile
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/cfnlego
|
72
|
+
- cfnlego.gemspec
|
73
|
+
- lib/cfnlego.rb
|
74
|
+
- lib/cfnlego/cloudformation.erb
|
75
|
+
- lib/cfnlego/cloudformation.rb
|
76
|
+
- lib/cfnlego/resource.rb
|
77
|
+
- lib/cfnlego/resources/AutoScaling/AutoScalingGroup.yaml
|
78
|
+
- lib/cfnlego/resources/AutoScaling/LaunchConfiguration.yaml
|
79
|
+
- lib/cfnlego/resources/AutoScaling/LifecycleHook.yaml
|
80
|
+
- lib/cfnlego/resources/IAM/InstanceProfile.yaml
|
81
|
+
- lib/cfnlego/resources/IAM/Role.yaml
|
82
|
+
- lib/cfnlego/version.rb
|
83
|
+
homepage: https://github.com/allinwonder/cfnlego
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.6
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Command Line tool to bootstrap CloudForamtion development with cfndsl
|
107
|
+
test_files: []
|