lono 3.5.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +15 -1
- data/Gemfile +3 -3
- data/Guardfile +17 -8
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +20 -12
- data/Rakefile +1 -2
- data/{bin → exe}/lono +1 -0
- data/lib/lono.rb +12 -9
- data/lib/lono/cfn.rb +7 -9
- data/lib/lono/cfn/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/cfn/base.rb +41 -38
- data/lib/lono/cfn/create.rb +6 -2
- data/lib/lono/cfn/delete.rb +2 -2
- data/lib/lono/cfn/diff.rb +1 -1
- data/lib/lono/cfn/preview.rb +26 -15
- data/lib/lono/cfn/update.rb +11 -9
- data/lib/lono/cfn/util.rb +3 -3
- data/lib/lono/clean.rb +1 -1
- data/lib/lono/cli.rb +71 -39
- data/lib/lono/command.rb +42 -18
- data/lib/lono/completer.rb +162 -0
- data/lib/lono/completer/script.rb +6 -0
- data/lib/lono/completer/script.sh +10 -0
- data/lib/lono/completion.rb +15 -0
- data/lib/lono/core.rb +23 -9
- data/lib/lono/core/config.rb +20 -0
- data/lib/lono/default/settings.yml +33 -13
- data/lib/lono/help.rb +6 -79
- data/lib/lono/help/cfn.md +6 -0
- data/lib/lono/help/cfn/create.md +22 -0
- data/lib/lono/help/cfn/delete.md +5 -0
- data/lib/lono/help/cfn/diff.md +5 -0
- data/lib/lono/help/cfn/download.md +5 -0
- data/lib/lono/help/cfn/preview.md +11 -0
- data/lib/lono/help/cfn/update.md +21 -0
- data/lib/lono/help/completion.md +22 -0
- data/lib/lono/help/completion_script.md +3 -0
- data/lib/lono/help/generate.md +7 -0
- data/lib/lono/help/hello.md +5 -0
- data/lib/lono/help/import.md +7 -0
- data/lib/lono/help/inspect.md +4 -0
- data/lib/lono/help/inspect/depends.md +3 -0
- data/lib/lono/help/inspect/summary.md +3 -0
- data/lib/lono/help/new.md +8 -0
- data/lib/lono/help/param.md +3 -0
- data/lib/lono/{param/help.rb → help/param/generate.md} +1 -9
- data/lib/lono/help/script/build.md +5 -0
- data/lib/lono/help/script/upload.md +8 -0
- data/lib/lono/help/template.md +4 -0
- data/lib/lono/help/template/bashify.md +4 -0
- data/lib/lono/help/template/generate.md +7 -0
- data/lib/lono/help/user_data.md +3 -0
- data/lib/lono/importer.rb +43 -20
- data/lib/lono/inspector.rb +2 -19
- data/lib/lono/inspector/base.rb +2 -2
- data/lib/lono/inspector/{depends.rb → graph.rb} +3 -3
- data/lib/lono/inspector/summary.rb +1 -1
- data/lib/lono/new.rb +79 -26
- data/lib/lono/new/helper.rb +16 -0
- data/lib/lono/new/message.rb +35 -0
- data/lib/lono/param.rb +1 -2
- data/lib/lono/param/generator.rb +34 -86
- data/lib/lono/project_checker.rb +35 -40
- data/lib/lono/script.rb +19 -0
- data/lib/lono/script/base.rb +9 -0
- data/lib/lono/script/build.rb +73 -0
- data/lib/lono/script/upload.rb +81 -0
- data/lib/lono/sequence.rb +33 -0
- data/lib/lono/setting.rb +83 -0
- data/lib/lono/template.rb +8 -9
- data/lib/lono/template/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/template/context.rb +73 -0
- data/lib/lono/template/dsl.rb +63 -64
- data/lib/lono/template/helper.rb +201 -0
- data/lib/lono/template/template.rb +29 -221
- data/lib/lono/template/upload.rb +41 -33
- data/lib/lono/upgrade4.rb +175 -0
- data/lib/lono/user_data.rb +31 -0
- data/lib/lono/version.rb +1 -1
- data/lib/starter_projects/autoscaling/.gitignore +1 -0
- data/lib/starter_projects/{json_project → autoscaling}/Gemfile +0 -0
- data/lib/starter_projects/{yaml_project → autoscaling}/Guardfile +0 -0
- data/lib/starter_projects/autoscaling/README.md +118 -0
- data/lib/starter_projects/autoscaling/app/definitions/base.rb +2 -0
- data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +682 -0
- data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +6 -0
- data/lib/starter_projects/autoscaling/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/.gitignore +1 -0
- data/lib/starter_projects/{yaml_project → ec2}/Gemfile +0 -0
- data/lib/starter_projects/{json_project → ec2}/Guardfile +1 -1
- data/lib/starter_projects/ec2/README.md +86 -0
- data/lib/starter_projects/ec2/app/definitions/base.rb +2 -0
- data/lib/starter_projects/ec2/app/definitions/development.rb +1 -0
- data/lib/starter_projects/ec2/app/definitions/production.rb +1 -0
- data/lib/starter_projects/{yaml_project → ec2/app}/helpers/my_custom_helper.rb +0 -0
- data/lib/starter_projects/{json_project/templates/user_data/app.sh → ec2/app/partials/user_data/bootstrap.sh} +1 -2
- data/lib/starter_projects/{yaml_project → ec2/app}/templates/example.yml +0 -0
- data/lib/starter_projects/{json_project/params/base/api-web.txt → ec2/config/params/base/example.txt} +0 -0
- data/lib/starter_projects/ec2/config/params/development/example.txt +3 -0
- data/lib/starter_projects/ec2/config/params/production/example.txt +2 -0
- data/lib/starter_projects/ec2/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/config/variables/base.rb +3 -0
- data/lib/starter_projects/ec2/config/variables/development.rb +2 -0
- data/lib/starter_projects/ec2/config/variables/production.rb +2 -0
- data/lib/starter_projects/ec2/welcome.txt +8 -0
- data/lib/starter_projects/skeleton/.gitignore +1 -0
- data/lib/starter_projects/skeleton/Gemfile +3 -0
- data/lib/starter_projects/skeleton/Guardfile +12 -0
- data/lib/starter_projects/skeleton/README.md +53 -0
- data/{spec/fixtures/my_project/templates/.gitkeep → lib/starter_projects/skeleton/app/definitions/base.rb} +0 -0
- data/lib/starter_projects/skeleton/config/settings.yml +33 -0
- data/lib/starter_projects/skeleton/welcome.txt +7 -0
- data/lono.gemspec +12 -10
- data/spec/fixtures/lono_project/.gitignore +1 -0
- data/spec/fixtures/lono_project/Gemfile +3 -0
- data/spec/fixtures/lono_project/Guardfile +12 -0
- data/spec/fixtures/lono_project/app/definitions/base.rb +10 -0
- data/spec/fixtures/lono_project/app/definitions/base/more.rb +7 -0
- data/spec/fixtures/lono_project/app/definitions/development.rb +1 -0
- data/spec/fixtures/lono_project/app/definitions/production.rb +1 -0
- data/spec/fixtures/lono_project/app/helpers/custom_helper.rb +5 -0
- data/spec/fixtures/lono_project/app/partials/security_group.yml +10 -0
- data/{lib/starter_projects/yaml_project/templates/partial → spec/fixtures/lono_project/app/partials}/user_data/bootstrap.sh +8 -2
- data/spec/fixtures/lono_project/app/templates/example.yml +50 -0
- data/{lib/starter_projects/yaml_project/params/base/api-web-prod.txt → spec/fixtures/lono_project/config/params/base/example.txt} +1 -0
- data/spec/fixtures/lono_project/config/params/development/example.txt +1 -0
- data/spec/fixtures/lono_project/config/params/production/example.txt +1 -0
- data/spec/fixtures/lono_project/config/settings.yml +31 -0
- data/spec/fixtures/lono_project/config/variables/base.rb +3 -0
- data/spec/fixtures/lono_project/config/variables/development.rb +1 -0
- data/spec/fixtures/lono_project/config/variables/production.rb +1 -0
- data/spec/fixtures/params/envonly/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/params/overlay/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/raw_templates/aws-waf-security-automations.template +2 -2
- data/spec/lib/lono/cfn_spec.rb +6 -9
- data/spec/lib/lono/cli_spec.rb +44 -0
- data/spec/lib/lono/completion_spec.rb +17 -0
- data/spec/lib/lono/inspect_spec.rb +6 -15
- data/spec/lib/lono/param/generator_spec.rb +45 -26
- data/spec/lib/lono/param_spec.rb +1 -3
- data/spec/lib/lono/setting_spec.rb +47 -0
- data/spec/lib/lono/template/dsl_spec.rb +33 -157
- data/spec/lib/lono/template_spec.rb +4 -16
- data/spec/spec_helper.rb +45 -14
- metadata +168 -82
- data/.coveralls.yml +0 -1
- data/lib/lono/cfn/help.rb +0 -103
- data/lib/lono/current_region.rb +0 -42
- data/lib/lono/inspector/help.rb +0 -21
- data/lib/lono/settings.rb +0 -45
- data/lib/lono/template/help.rb +0 -25
- data/lib/lono/template/helpers.rb +0 -136
- data/lib/starter_projects/json_project/.gitignore +0 -1
- data/lib/starter_projects/json_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/json_project/config/templates/base/stacks.rb +0 -58
- data/lib/starter_projects/json_project/templates/db.json +0 -212
- data/lib/starter_projects/json_project/templates/partial/host_record.json +0 -28
- data/lib/starter_projects/json_project/templates/partial/server.json +0 -45
- data/lib/starter_projects/json_project/templates/user_data/db.sh +0 -39
- data/lib/starter_projects/json_project/templates/user_data/db2.sh +0 -2
- data/lib/starter_projects/json_project/templates/user_data/ruby_script.rb +0 -5
- data/lib/starter_projects/json_project/templates/web.json +0 -386
- data/lib/starter_projects/yaml_project/.gitignore +0 -1
- data/lib/starter_projects/yaml_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/yaml_project/config/templates/base/stacks.rb +0 -56
- data/lib/starter_projects/yaml_project/config/templates/prod/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/templates/stag/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/base/variables.rb +0 -4
- data/lib/starter_projects/yaml_project/config/variables/prod/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/stag/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/params/base/example.txt +0 -2
- data/lib/starter_projects/yaml_project/params/prod/example.txt +0 -1
- data/lib/starter_projects/yaml_project/params/stag/example.txt +0 -1
- data/lib/starter_projects/yaml_project/templates/db.yml +0 -148
- data/lib/starter_projects/yaml_project/templates/partial/host_record.yml +0 -14
- data/lib/starter_projects/yaml_project/templates/partial/server.yml +0 -59
- data/lib/starter_projects/yaml_project/templates/web.yml +0 -206
- data/spec/fixtures/my_project/config/templates/base/stacks.rb +0 -3
- data/spec/fixtures/my_project/params/my-stack.txt +0 -3
- data/spec/fixtures/my_project/templates/my-stack.yml +0 -0
- data/spec/lib/lono/new_spec.rb +0 -59
- data/spec/lib/lono/template/template_spec.rb +0 -104
- data/spec/lib/lono_spec.rb +0 -27
@@ -1,212 +0,0 @@
|
|
1
|
-
<% @app,@role,@env = name.sub('.json','').split('-') %>
|
2
|
-
{
|
3
|
-
"AWSTemplateFormatVersion": "2010-09-09",
|
4
|
-
"Description": "<%= @app.capitalize %> <%= @role %>",
|
5
|
-
"Outputs": {
|
6
|
-
"DBHostname": {
|
7
|
-
"Description": "Hostname for Redis",
|
8
|
-
"Value": {
|
9
|
-
"Fn::Join": [
|
10
|
-
"",
|
11
|
-
[
|
12
|
-
"",
|
13
|
-
{
|
14
|
-
"Fn::GetAtt": [
|
15
|
-
"server",
|
16
|
-
"PublicDnsName"
|
17
|
-
]
|
18
|
-
}
|
19
|
-
]
|
20
|
-
]
|
21
|
-
}
|
22
|
-
}
|
23
|
-
},
|
24
|
-
"Parameters": {
|
25
|
-
"Ami": {
|
26
|
-
"Default": "<%= @ami %>",
|
27
|
-
"Description": "deploy ami",
|
28
|
-
"Type": "String"
|
29
|
-
},
|
30
|
-
"Application": {
|
31
|
-
"Default": "<%= @app %>",
|
32
|
-
"Description": "foo, bar, etc",
|
33
|
-
"Type": "String"
|
34
|
-
},
|
35
|
-
"Environment": {
|
36
|
-
"Default": "<%= @env %>",
|
37
|
-
"Description": "stag, prod etc",
|
38
|
-
"Type": "String"
|
39
|
-
},
|
40
|
-
"InstanceType": {
|
41
|
-
"AllowedValues": [
|
42
|
-
"t1.micro",
|
43
|
-
"m1.small",
|
44
|
-
"m1.medium",
|
45
|
-
"m1.large",
|
46
|
-
"m1.xlarge",
|
47
|
-
"m2.xlarge",
|
48
|
-
"m2.2xlarge",
|
49
|
-
"m2.4xlarge",
|
50
|
-
"c1.medium",
|
51
|
-
"c1.xlarge",
|
52
|
-
"cc1.4xlarge",
|
53
|
-
"cc2.8xlarge",
|
54
|
-
"cg1.4xlarge"
|
55
|
-
],
|
56
|
-
"ConstraintDescription": "must be a valid EC2 instance type.",
|
57
|
-
"Default": "<%= @instance_type %>",
|
58
|
-
"Description": "server EC2 instance type",
|
59
|
-
"Type": "String"
|
60
|
-
},
|
61
|
-
"KeyName": {
|
62
|
-
"AllowedPattern": "[-_ a-zA-Z0-9]*",
|
63
|
-
"ConstraintDescription": "can contain only alphanumeric characters, spaces, dashes and underscores.",
|
64
|
-
"Default": "default",
|
65
|
-
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
66
|
-
"MaxLength": "64",
|
67
|
-
"MinLength": "1",
|
68
|
-
"Type": "String"
|
69
|
-
},
|
70
|
-
"Role": {
|
71
|
-
"Default": "<%= @role %>",
|
72
|
-
"Description": "redis, psql, app, etc",
|
73
|
-
"Type": "String"
|
74
|
-
},
|
75
|
-
"StackNumber": {
|
76
|
-
"Default": "<%= @stack_number %>",
|
77
|
-
"Description": "s1, s2, s3, etc",
|
78
|
-
"Type": "String"
|
79
|
-
},
|
80
|
-
"VolumeSize": {
|
81
|
-
"ConstraintDescription": "must be between 5 and 1024 Gb.",
|
82
|
-
"Default": "<%= @volume_size %>",
|
83
|
-
"Description": "Size of Volume",
|
84
|
-
"MaxValue": "1024",
|
85
|
-
"MinValue": "5",
|
86
|
-
"Type": "Number"
|
87
|
-
}
|
88
|
-
},
|
89
|
-
"Resources": {
|
90
|
-
"CfnUser": {
|
91
|
-
"Properties": {
|
92
|
-
"Path": "/",
|
93
|
-
"Policies": [
|
94
|
-
{
|
95
|
-
"PolicyDocument": {
|
96
|
-
"Statement": [
|
97
|
-
{
|
98
|
-
"Action": "cloudformation:DescribeStackResource",
|
99
|
-
"Effect": "Allow",
|
100
|
-
"Resource": "*"
|
101
|
-
}
|
102
|
-
]
|
103
|
-
},
|
104
|
-
"PolicyName": "root"
|
105
|
-
}
|
106
|
-
]
|
107
|
-
},
|
108
|
-
"Type": "AWS::IAM::User"
|
109
|
-
},
|
110
|
-
"DataVolume": {
|
111
|
-
"DeletionPolicy": "Snapshot",
|
112
|
-
"Properties": {
|
113
|
-
"AvailabilityZone": {
|
114
|
-
"Fn::GetAtt": [
|
115
|
-
"server",
|
116
|
-
"AvailabilityZone"
|
117
|
-
]
|
118
|
-
},
|
119
|
-
"Size": {
|
120
|
-
"Ref": "VolumeSize"
|
121
|
-
},
|
122
|
-
"Tags": [
|
123
|
-
{
|
124
|
-
"Key": "Usage",
|
125
|
-
"Value": "Data Volume"
|
126
|
-
}
|
127
|
-
]
|
128
|
-
},
|
129
|
-
"Type": "AWS::EC2::Volume"
|
130
|
-
},
|
131
|
-
"HostKeys": {
|
132
|
-
"Properties": {
|
133
|
-
"UserName": {
|
134
|
-
"Ref": "CfnUser"
|
135
|
-
}
|
136
|
-
},
|
137
|
-
"Type": "AWS::IAM::AccessKey"
|
138
|
-
},
|
139
|
-
"HostRecord": {
|
140
|
-
"Properties": {
|
141
|
-
"Comment": "DNS name for my stack.",
|
142
|
-
"HostedZoneName": ".mydomain.net.",
|
143
|
-
"Name": {
|
144
|
-
"Fn::Join": [
|
145
|
-
"",
|
146
|
-
[
|
147
|
-
{
|
148
|
-
"Ref": "AWS::StackName"
|
149
|
-
},
|
150
|
-
".mydomain.net."
|
151
|
-
]
|
152
|
-
]
|
153
|
-
},
|
154
|
-
"ResourceRecords": [
|
155
|
-
{
|
156
|
-
"Fn::GetAtt": [
|
157
|
-
"server",
|
158
|
-
"PublicDnsName"
|
159
|
-
]
|
160
|
-
}
|
161
|
-
],
|
162
|
-
"TTL": "60",
|
163
|
-
"Type": "CNAME"
|
164
|
-
},
|
165
|
-
"Type": "AWS::Route53::RecordSet"
|
166
|
-
},
|
167
|
-
"MountPoint": {
|
168
|
-
"Properties": {
|
169
|
-
"Device": "/dev/sdf",
|
170
|
-
"InstanceId": {
|
171
|
-
"Ref": "server"
|
172
|
-
},
|
173
|
-
"VolumeId": {
|
174
|
-
"Ref": "DataVolume"
|
175
|
-
}
|
176
|
-
},
|
177
|
-
"Type": "AWS::EC2::VolumeAttachment"
|
178
|
-
},
|
179
|
-
"ServiceSecurityGroup": {
|
180
|
-
"Properties": {
|
181
|
-
"GroupDescription": "Enable SSH access.",
|
182
|
-
"SecurityGroupIngress": [
|
183
|
-
{
|
184
|
-
"CidrIp": "0.0.0.0/0",
|
185
|
-
"FromPort": "22",
|
186
|
-
"IpProtocol": "tcp",
|
187
|
-
"ToPort": "22"
|
188
|
-
}
|
189
|
-
]
|
190
|
-
},
|
191
|
-
"Type": "AWS::EC2::SecurityGroup"
|
192
|
-
},
|
193
|
-
"WaitCondition": {
|
194
|
-
"DependsOn": "MountPoint",
|
195
|
-
"Metadata": {
|
196
|
-
"Comment1": "Note that the WaitCondition is dependent on the volume mount point allowing the volume to be created and attached to the EC2 instance",
|
197
|
-
"Comment2": "The instance bootstrap script waits for the volume to be attached to the instance prior to signalling completion."
|
198
|
-
},
|
199
|
-
"Properties": {
|
200
|
-
"Handle": {
|
201
|
-
"Ref": "WaitHandle"
|
202
|
-
},
|
203
|
-
"Timeout": "3000"
|
204
|
-
},
|
205
|
-
"Type": "AWS::CloudFormation::WaitCondition"
|
206
|
-
},
|
207
|
-
"WaitHandle": {
|
208
|
-
"Type": "AWS::CloudFormation::WaitConditionHandle"
|
209
|
-
},
|
210
|
-
<%= partial("server") %>
|
211
|
-
}
|
212
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"HostRecord": {
|
2
|
-
"Properties": {
|
3
|
-
"Comment": "DNS name for <%= @domain %>",
|
4
|
-
"HostedZoneName": ".mydomain.net.",
|
5
|
-
"Name": {
|
6
|
-
"Fn::Join": [
|
7
|
-
"",
|
8
|
-
[
|
9
|
-
{
|
10
|
-
"Ref": "AWS::StackName"
|
11
|
-
},
|
12
|
-
".<%= @domain %>"
|
13
|
-
]
|
14
|
-
]
|
15
|
-
},
|
16
|
-
"ResourceRecords": [
|
17
|
-
{
|
18
|
-
"Fn::GetAtt": [
|
19
|
-
"elb",
|
20
|
-
"DNSName"
|
21
|
-
]
|
22
|
-
}
|
23
|
-
],
|
24
|
-
"TTL": "60",
|
25
|
-
"Type": "CNAME"
|
26
|
-
},
|
27
|
-
"Type": "AWS::Route53::RecordSet"
|
28
|
-
},
|
@@ -1,45 +0,0 @@
|
|
1
|
-
"server": {
|
2
|
-
"Properties": {
|
3
|
-
"AvailabilityZone": "<%= @availability_zone %>",
|
4
|
-
"ImageId": {
|
5
|
-
"Ref": "Ami"
|
6
|
-
},
|
7
|
-
"InstanceType": {
|
8
|
-
"Ref": "InstanceType"
|
9
|
-
},
|
10
|
-
"KeyName": {
|
11
|
-
"Ref": "KeyName"
|
12
|
-
},
|
13
|
-
"SecurityGroups": [
|
14
|
-
"global",
|
15
|
-
{
|
16
|
-
"Fn::Join": [
|
17
|
-
"-",
|
18
|
-
[
|
19
|
-
{
|
20
|
-
"Ref": "Environment"
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"Ref": "Application"
|
24
|
-
}
|
25
|
-
]
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"Ref": "ServiceSecurityGroup"
|
30
|
-
}
|
31
|
-
],
|
32
|
-
"UserData": {
|
33
|
-
"Fn::Base64": {
|
34
|
-
"Fn::Join": [
|
35
|
-
"",
|
36
|
-
[
|
37
|
-
<%= user_data('db.sh', vartest: 'foo') %>,
|
38
|
-
<%= user_data('db2.sh') %>
|
39
|
-
]
|
40
|
-
]
|
41
|
-
}
|
42
|
-
}
|
43
|
-
},
|
44
|
-
"Type": "AWS::EC2::Instance"
|
45
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/bin/bash -lexv
|
2
|
-
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
|
3
|
-
|
4
|
-
FIND_IN_MAP=<%= find_in_map("MapName", "TopLevelKey", "SecondLevelKey") %>
|
5
|
-
HOSTNAME_PREFIX=<%= find_in_map("EnvironmentMapping", "HostnamePrefix", ref("Environment")) %>
|
6
|
-
BAR=<%= ref("DRINK") %> ; MORE=<%= find_in_map("MapName", "TopLevelKey", "SecondLevelKey") %>
|
7
|
-
|
8
|
-
BASE64=<%= base64("value to encode") %>
|
9
|
-
GET_ATT=<%= get_att("server", "PublicDnsName") %>
|
10
|
-
GET_AZS=<%= get_azs %>
|
11
|
-
JOIN=<%= join(":", ['a','b','c']) %>
|
12
|
-
SELECT=<%= select("1", ['a','b','c']) %>
|
13
|
-
|
14
|
-
VARTEST=<%= @vartest %>
|
15
|
-
|
16
|
-
echo <%= ref("AWS::StackName") %> > /tmp/stack_name
|
17
|
-
# Helper function
|
18
|
-
function error_exit
|
19
|
-
{
|
20
|
-
/usr/local/bin/cfn-signal -e 1 -r "$1" '<%= ref("WaitHandle") %>'
|
21
|
-
exit 1
|
22
|
-
}
|
23
|
-
# Wait for the EBS volume to show up
|
24
|
-
while [ ! -e /dev/xvdf ]; do echo Waiting for EBS volume to attach; sleep 1; done
|
25
|
-
/bin/mkdir /media/redis
|
26
|
-
/sbin/mkfs -t ext4 /dev/xvdf
|
27
|
-
echo "/dev/xvdf /media/redis auto defaults 0 0" >> /etc/fstab
|
28
|
-
/bin/mount /media/redis
|
29
|
-
/usr/bin/redis-cli shutdown
|
30
|
-
sleep 10
|
31
|
-
mv /var/lib/redis/* /media/redis/
|
32
|
-
rm -r /var/lib/redis
|
33
|
-
ln -s /media/redis /var/lib/redis
|
34
|
-
chown -R redis:redis /var/lib/redis
|
35
|
-
chown -R redis:redis /media/redis
|
36
|
-
/usr/bin/redis-server
|
37
|
-
# If all is well so signal success
|
38
|
-
/usr/local/bin/cfn-signal -e $? -r "Ready to rock" '<%= ref("WaitHandle") %>'
|
39
|
-
cat /proc/uptime | cut -f1 -d'.' > /tmp/time-to-boot
|
@@ -1,386 +0,0 @@
|
|
1
|
-
<% @app,@role,@env = name.sub('.json','').split('-') %>
|
2
|
-
{
|
3
|
-
"AWSTemplateFormatVersion": "2010-09-09",
|
4
|
-
"Description": "<%= @app.capitalize %> Stack",
|
5
|
-
"Mappings": {
|
6
|
-
"AWSInstanceType2Arch": {
|
7
|
-
"c1.medium": {
|
8
|
-
"Arch": "64"
|
9
|
-
},
|
10
|
-
"c1.xlarge": {
|
11
|
-
"Arch": "64"
|
12
|
-
},
|
13
|
-
"cc1.4xlarge": {
|
14
|
-
"Arch": "64"
|
15
|
-
},
|
16
|
-
"cc2.8xlarge": {
|
17
|
-
"Arch": "64"
|
18
|
-
},
|
19
|
-
"cg1.4xlarge": {
|
20
|
-
"Arch": "64"
|
21
|
-
},
|
22
|
-
"m1.large": {
|
23
|
-
"Arch": "64"
|
24
|
-
},
|
25
|
-
"m1.medium": {
|
26
|
-
"Arch": "64"
|
27
|
-
},
|
28
|
-
"m1.small": {
|
29
|
-
"Arch": "64"
|
30
|
-
},
|
31
|
-
"m1.xlarge": {
|
32
|
-
"Arch": "64"
|
33
|
-
},
|
34
|
-
"m2.2xlarge": {
|
35
|
-
"Arch": "64"
|
36
|
-
},
|
37
|
-
"m2.4xlarge": {
|
38
|
-
"Arch": "64"
|
39
|
-
},
|
40
|
-
"m2.xlarge": {
|
41
|
-
"Arch": "64"
|
42
|
-
},
|
43
|
-
"t1.micro": {
|
44
|
-
"Arch": "64"
|
45
|
-
}
|
46
|
-
},
|
47
|
-
"AWSRegionArch2AMI": {
|
48
|
-
"us-east-1": {
|
49
|
-
"32": "",
|
50
|
-
"64": "<%= @ami %>"
|
51
|
-
},
|
52
|
-
"us-west-1": {
|
53
|
-
"32": "",
|
54
|
-
"64": ""
|
55
|
-
}
|
56
|
-
}
|
57
|
-
},
|
58
|
-
"Outputs": {
|
59
|
-
"ELBHostname": {
|
60
|
-
"Description": "The URL of the website",
|
61
|
-
"Value": {
|
62
|
-
"Fn::Join": [
|
63
|
-
"",
|
64
|
-
[
|
65
|
-
"http://",
|
66
|
-
{
|
67
|
-
"Fn::GetAtt": [
|
68
|
-
"elb",
|
69
|
-
"DNSName"
|
70
|
-
]
|
71
|
-
}
|
72
|
-
]
|
73
|
-
]
|
74
|
-
}
|
75
|
-
}
|
76
|
-
},
|
77
|
-
"Parameters": {
|
78
|
-
"Application": {
|
79
|
-
"Default": "<%= @app %>",
|
80
|
-
"Description": "Application name",
|
81
|
-
"Type": "String"
|
82
|
-
},
|
83
|
-
"Environment": {
|
84
|
-
"Default": "<%= @env %>",
|
85
|
-
"Description": "stag, prod etc",
|
86
|
-
"Type": "String"
|
87
|
-
},
|
88
|
-
"InstanceType": {
|
89
|
-
"AllowedValues": [
|
90
|
-
"t1.micro",
|
91
|
-
"m1.small",
|
92
|
-
"m1.medium",
|
93
|
-
"m1.large",
|
94
|
-
"m1.xlarge",
|
95
|
-
"m2.xlarge",
|
96
|
-
"m2.2xlarge",
|
97
|
-
"m2.4xlarge",
|
98
|
-
"c1.medium",
|
99
|
-
"c1.xlarge",
|
100
|
-
"cc1.4xlarge",
|
101
|
-
"cc2.8xlarge",
|
102
|
-
"cg1.4xlarge"
|
103
|
-
],
|
104
|
-
"ConstraintDescription": "must be a valid EC2 instance type.",
|
105
|
-
"Default": "<%= @instance_type %>",
|
106
|
-
"Description": "WebServer EC2 instance type",
|
107
|
-
"Type": "String"
|
108
|
-
},
|
109
|
-
"KeyName": {
|
110
|
-
"Default": "default",
|
111
|
-
"Description": "The EC2 Key Pair to allow SSH access to the instances",
|
112
|
-
"Type": "String"
|
113
|
-
},
|
114
|
-
"Role": {
|
115
|
-
"Default": "<%= @role %>",
|
116
|
-
"Description": "redis, psql, app, etc",
|
117
|
-
"Type": "String"
|
118
|
-
},
|
119
|
-
"StackNumber": {
|
120
|
-
"Description": "s1, s2, s3, etc",
|
121
|
-
"Type": "String"
|
122
|
-
},
|
123
|
-
"WebServerPort": {
|
124
|
-
"Default": "<%= @port %>",
|
125
|
-
"Description": "The TCP port for the Web Server",
|
126
|
-
"Type": "Number"
|
127
|
-
}
|
128
|
-
},
|
129
|
-
"Resources": {
|
130
|
-
"CPUAlarmHigh": {
|
131
|
-
"Properties": {
|
132
|
-
"AlarmActions": [
|
133
|
-
{
|
134
|
-
"Ref": "WebServerScaleUpPolicy"
|
135
|
-
}
|
136
|
-
],
|
137
|
-
"AlarmDescription": "Scale-up if CPU > <%= @high_threshold %>% for <%= @high_mins %> minutes",
|
138
|
-
"ComparisonOperator": "GreaterThanThreshold",
|
139
|
-
"Dimensions": [
|
140
|
-
{
|
141
|
-
"Name": "AutoScalingGroupName",
|
142
|
-
"Value": {
|
143
|
-
"Ref": "WebServerGroup"
|
144
|
-
}
|
145
|
-
}
|
146
|
-
],
|
147
|
-
"EvaluationPeriods": "<%= @high_periods %>",
|
148
|
-
"MetricName": "CPUUtilization",
|
149
|
-
"Namespace": "AWS/EC2",
|
150
|
-
"Period": "60",
|
151
|
-
"Statistic": "Average",
|
152
|
-
"Threshold": "<%= @high_threshold %>"
|
153
|
-
},
|
154
|
-
"Type": "AWS::CloudWatch::Alarm"
|
155
|
-
},
|
156
|
-
"CPUAlarmLow": {
|
157
|
-
"Properties": {
|
158
|
-
"AlarmActions": [
|
159
|
-
{
|
160
|
-
"Ref": "WebServerScaleDownPolicy"
|
161
|
-
}
|
162
|
-
],
|
163
|
-
"AlarmDescription": "Scale-down if CPU < <%= @low_threshold %>% for 10 minutes",
|
164
|
-
"ComparisonOperator": "LessThanThreshold",
|
165
|
-
"Dimensions": [
|
166
|
-
{
|
167
|
-
"Name": "AutoScalingGroupName",
|
168
|
-
"Value": {
|
169
|
-
"Ref": "WebServerGroup"
|
170
|
-
}
|
171
|
-
}
|
172
|
-
],
|
173
|
-
"EvaluationPeriods": "<%= @low_periods %>",
|
174
|
-
"MetricName": "CPUUtilization",
|
175
|
-
"Namespace": "AWS/EC2",
|
176
|
-
"Period": "60",
|
177
|
-
"Statistic": "Average",
|
178
|
-
"Threshold": "<%= @low_threshold %>"
|
179
|
-
},
|
180
|
-
"Type": "AWS::CloudWatch::Alarm"
|
181
|
-
},
|
182
|
-
<%= partial("host_record", domain: "mydomain.com") %>
|
183
|
-
"LaunchConfig": {
|
184
|
-
"Properties": {
|
185
|
-
"BlockDeviceMappings": [
|
186
|
-
{
|
187
|
-
"DeviceName": "/dev/sdb",
|
188
|
-
"VirtualName": "ephemeral0"
|
189
|
-
}
|
190
|
-
],
|
191
|
-
"ImageId": {
|
192
|
-
"Fn::FindInMap": [
|
193
|
-
"AWSRegionArch2AMI",
|
194
|
-
{
|
195
|
-
"Ref": "AWS::Region"
|
196
|
-
},
|
197
|
-
{
|
198
|
-
"Fn::FindInMap": [
|
199
|
-
"AWSInstanceType2Arch",
|
200
|
-
{
|
201
|
-
"Ref": "InstanceType"
|
202
|
-
},
|
203
|
-
"Arch"
|
204
|
-
]
|
205
|
-
}
|
206
|
-
]
|
207
|
-
},
|
208
|
-
"InstanceType": {
|
209
|
-
"Ref": "InstanceType"
|
210
|
-
},
|
211
|
-
"KeyName": {
|
212
|
-
"Ref": "KeyName"
|
213
|
-
},
|
214
|
-
"SecurityGroups": [
|
215
|
-
"global",
|
216
|
-
{
|
217
|
-
"Fn::Join": [
|
218
|
-
"-",
|
219
|
-
[
|
220
|
-
{
|
221
|
-
"Ref": "Environment"
|
222
|
-
},
|
223
|
-
{
|
224
|
-
"Ref": "Application"
|
225
|
-
}
|
226
|
-
]
|
227
|
-
]
|
228
|
-
},
|
229
|
-
{
|
230
|
-
"Ref": "ServiceSecurityGroup"
|
231
|
-
}
|
232
|
-
],
|
233
|
-
"UserData": {
|
234
|
-
"Fn::Base64": {
|
235
|
-
"Fn::Join": [
|
236
|
-
"",
|
237
|
-
[
|
238
|
-
<% script = @user_data_script || 'app.sh' %>
|
239
|
-
<%= user_data(script) %>
|
240
|
-
]
|
241
|
-
]
|
242
|
-
}
|
243
|
-
}
|
244
|
-
},
|
245
|
-
"Type": "AWS::AutoScaling::LaunchConfiguration"
|
246
|
-
},
|
247
|
-
"ServiceSecurityGroup": {
|
248
|
-
"Properties": {
|
249
|
-
"GroupDescription": "Enable SSH access and HTTP from the load balancer only",
|
250
|
-
"SecurityGroupIngress": [
|
251
|
-
{
|
252
|
-
"CidrIp": "0.0.0.0/0",
|
253
|
-
"FromPort": "22",
|
254
|
-
"IpProtocol": "tcp",
|
255
|
-
"ToPort": "22"
|
256
|
-
},
|
257
|
-
{
|
258
|
-
"FromPort": {
|
259
|
-
"Ref": "WebServerPort"
|
260
|
-
},
|
261
|
-
"IpProtocol": "tcp",
|
262
|
-
"SourceSecurityGroupName": {
|
263
|
-
"Fn::GetAtt": [
|
264
|
-
"elb",
|
265
|
-
"SourceSecurityGroup.GroupName"
|
266
|
-
]
|
267
|
-
},
|
268
|
-
"SourceSecurityGroupOwnerId": {
|
269
|
-
"Fn::GetAtt": [
|
270
|
-
"elb",
|
271
|
-
"SourceSecurityGroup.OwnerAlias"
|
272
|
-
]
|
273
|
-
},
|
274
|
-
"ToPort": {
|
275
|
-
"Ref": "WebServerPort"
|
276
|
-
}
|
277
|
-
}
|
278
|
-
]
|
279
|
-
},
|
280
|
-
"Type": "AWS::EC2::SecurityGroup"
|
281
|
-
},
|
282
|
-
"WebServerGroup": {
|
283
|
-
"Properties": {
|
284
|
-
"AvailabilityZones": [
|
285
|
-
"us-east-1a",
|
286
|
-
"us-east-1d",
|
287
|
-
"us-east-1e"
|
288
|
-
],
|
289
|
-
"HealthCheckGracePeriod": "300",
|
290
|
-
"HealthCheckType": "ELB",
|
291
|
-
"LaunchConfigurationName": {
|
292
|
-
"Ref": "LaunchConfig"
|
293
|
-
},
|
294
|
-
"LoadBalancerNames": [
|
295
|
-
{
|
296
|
-
"Ref": "elb"
|
297
|
-
}
|
298
|
-
],
|
299
|
-
"MaxSize": "<%= @max_size %>",
|
300
|
-
"MinSize": "<%= @min_size %>",
|
301
|
-
"NotificationConfiguration": {
|
302
|
-
"NotificationTypes": [
|
303
|
-
"autoscaling:EC2_INSTANCE_LAUNCH",
|
304
|
-
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
|
305
|
-
"autoscaling:EC2_INSTANCE_TERMINATE",
|
306
|
-
"autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
|
307
|
-
],
|
308
|
-
"TopicARN": [
|
309
|
-
"arn:aws:sns:us-east-1:867690557112:ops"
|
310
|
-
]
|
311
|
-
}
|
312
|
-
},
|
313
|
-
"Type": "AWS::AutoScaling::AutoScalingGroup"
|
314
|
-
},
|
315
|
-
"WebServerScaleDownPolicy": {
|
316
|
-
"Properties": {
|
317
|
-
"AdjustmentType": "ChangeInCapacity",
|
318
|
-
"AutoScalingGroupName": {
|
319
|
-
"Ref": "WebServerGroup"
|
320
|
-
},
|
321
|
-
"Cooldown": "120",
|
322
|
-
"ScalingAdjustment": "<%= @down_adjustment %>"
|
323
|
-
},
|
324
|
-
"Type": "AWS::AutoScaling::ScalingPolicy"
|
325
|
-
},
|
326
|
-
"WebServerScaleUpPolicy": {
|
327
|
-
"Properties": {
|
328
|
-
"AdjustmentType": "ChangeInCapacity",
|
329
|
-
"AutoScalingGroupName": {
|
330
|
-
"Ref": "WebServerGroup"
|
331
|
-
},
|
332
|
-
"Cooldown": "120",
|
333
|
-
"ScalingAdjustment": "<%= @up_adjustment %>"
|
334
|
-
},
|
335
|
-
"Type": "AWS::AutoScaling::ScalingPolicy"
|
336
|
-
},
|
337
|
-
"elb": {
|
338
|
-
"Properties": {
|
339
|
-
"AvailabilityZones": [
|
340
|
-
"us-east-1a",
|
341
|
-
"us-east-1d",
|
342
|
-
"us-east-1e"
|
343
|
-
],
|
344
|
-
"HealthCheck": {
|
345
|
-
"HealthyThreshold": "3",
|
346
|
-
"Interval": "6",
|
347
|
-
"Target": {
|
348
|
-
"Fn::Join": [
|
349
|
-
"",
|
350
|
-
[
|
351
|
-
"HTTP:",
|
352
|
-
{
|
353
|
-
"Ref": "WebServerPort"
|
354
|
-
},
|
355
|
-
"/up/elb"
|
356
|
-
]
|
357
|
-
]
|
358
|
-
},
|
359
|
-
"Timeout": "5",
|
360
|
-
"UnhealthyThreshold": "5"
|
361
|
-
},
|
362
|
-
"Listeners": [
|
363
|
-
{
|
364
|
-
"InstancePort": {
|
365
|
-
"Ref": "WebServerPort"
|
366
|
-
},
|
367
|
-
"LoadBalancerPort": "80",
|
368
|
-
"Protocol": "HTTP"
|
369
|
-
},
|
370
|
-
{
|
371
|
-
"InstancePort": {
|
372
|
-
"Ref": "WebServerPort"
|
373
|
-
},
|
374
|
-
"LoadBalancerPort": "443",
|
375
|
-
"PolicyNames": [
|
376
|
-
|
377
|
-
],
|
378
|
-
"Protocol": "HTTPS",
|
379
|
-
"SSLCertificateId": "<%= @ssl_cert %>"
|
380
|
-
}
|
381
|
-
]
|
382
|
-
},
|
383
|
-
"Type": "AWS::ElasticLoadBalancing::LoadBalancer"
|
384
|
-
}
|
385
|
-
}
|
386
|
-
}
|