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 +0,0 @@
|
|
1
|
-
/output
|
@@ -1,20 +0,0 @@
|
|
1
|
-
template "blog-web" do
|
2
|
-
app,role,env = name.split('-')
|
3
|
-
source "web"
|
4
|
-
variables(
|
5
|
-
env: env,
|
6
|
-
app: app,
|
7
|
-
role: role,
|
8
|
-
instance_type: "t2.small",
|
9
|
-
port: "80",
|
10
|
-
high_threshold: "35",
|
11
|
-
high_periods: "4",
|
12
|
-
low_threshold: "20",
|
13
|
-
low_periods: "2",
|
14
|
-
max_size: "6",
|
15
|
-
min_size: "3",
|
16
|
-
down_adjustment: "-1",
|
17
|
-
up_adjustment: "2"
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
template "example"
|
2
|
-
|
3
|
-
template "api-web" do
|
4
|
-
source "web"
|
5
|
-
variables(
|
6
|
-
instance_type: "t2.small",
|
7
|
-
port: "80",
|
8
|
-
high_threshold: "15",
|
9
|
-
high_periods: "4",
|
10
|
-
low_threshold: "5",
|
11
|
-
low_periods: "10",
|
12
|
-
max_size: "24",
|
13
|
-
min_size: "6",
|
14
|
-
down_adjustment: "-3",
|
15
|
-
up_adjustment: "3",
|
16
|
-
ssl_cert: "arn:aws:iam::12345:server-certificate/wildcard"
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
template "api-worker" do
|
21
|
-
source "web"
|
22
|
-
variables(
|
23
|
-
instance_type: "t2.small",
|
24
|
-
port: "80",
|
25
|
-
high_threshold: "15",
|
26
|
-
high_periods: "4",
|
27
|
-
low_threshold: "5",
|
28
|
-
low_periods: "10",
|
29
|
-
max_size: "24",
|
30
|
-
min_size: "6",
|
31
|
-
down_adjustment: "-3",
|
32
|
-
up_adjustment: "3",
|
33
|
-
user_data_script: "ruby_script.rb",
|
34
|
-
ssl_cert: "arn:aws:iam::12345:server-certificate/wildcard"
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
template "api-redis" do
|
39
|
-
source "db"
|
40
|
-
variables(
|
41
|
-
instance_type: "t2.small",
|
42
|
-
port: "80",
|
43
|
-
volume_size: "20",
|
44
|
-
availability_zone: "us-east-1e"
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
template "parent/db-stack" do
|
49
|
-
source "db"
|
50
|
-
variables(
|
51
|
-
instance_type: "t2.small",
|
52
|
-
port: "80",
|
53
|
-
volume_size: "20",
|
54
|
-
availability_zone: "us-east-1e"
|
55
|
-
)
|
56
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
# resources that only exist in the prod environment
|
@@ -1 +0,0 @@
|
|
1
|
-
# resources that only exist in the stag environment
|
@@ -1 +0,0 @@
|
|
1
|
-
@prod_override = "prod-override-test"
|
@@ -1 +0,0 @@
|
|
1
|
-
@stag_override = "stag-override-test"
|
@@ -1 +0,0 @@
|
|
1
|
-
InstanceType=m4.large
|
@@ -1 +0,0 @@
|
|
1
|
-
InstanceType=m4.small
|
@@ -1,148 +0,0 @@
|
|
1
|
-
<% @app,@role,@env = name.sub('.yml','').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
|
-
- Fn::GetAtt:
|
13
|
-
- server
|
14
|
-
- PublicDnsName
|
15
|
-
Parameters:
|
16
|
-
Ami:
|
17
|
-
Default: <%= @ami %>
|
18
|
-
Description: deploy ami
|
19
|
-
Type: String
|
20
|
-
Application:
|
21
|
-
Default: <%= @app %>
|
22
|
-
Description: foo, bar, etc
|
23
|
-
Type: String
|
24
|
-
Environment:
|
25
|
-
Default: <%= @env %>
|
26
|
-
Description: stag, prod etc
|
27
|
-
Type: String
|
28
|
-
InstanceType:
|
29
|
-
AllowedValues:
|
30
|
-
- t1.micro
|
31
|
-
- m1.small
|
32
|
-
- m1.medium
|
33
|
-
- m1.large
|
34
|
-
- m1.xlarge
|
35
|
-
- m2.xlarge
|
36
|
-
- m2.2xlarge
|
37
|
-
- m2.4xlarge
|
38
|
-
- c1.medium
|
39
|
-
- c1.xlarge
|
40
|
-
- cc1.4xlarge
|
41
|
-
- cc2.8xlarge
|
42
|
-
- cg1.4xlarge
|
43
|
-
ConstraintDescription: must be a valid EC2 instance type.
|
44
|
-
Default: <%= @instance_type %>
|
45
|
-
Description: server EC2 instance type
|
46
|
-
Type: String
|
47
|
-
KeyName:
|
48
|
-
AllowedPattern: "[-_ a-zA-Z0-9]*"
|
49
|
-
ConstraintDescription: can contain only alphanumeric characters, spaces, dashes
|
50
|
-
and underscores.
|
51
|
-
Default: default
|
52
|
-
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
|
53
|
-
MaxLength: '64'
|
54
|
-
MinLength: '1'
|
55
|
-
Type: String
|
56
|
-
Role:
|
57
|
-
Default: '<%= @role %>'
|
58
|
-
Description: redis, psql, app, etc
|
59
|
-
Type: String
|
60
|
-
StackNumber:
|
61
|
-
Default: ''
|
62
|
-
Description: s1, s2, s3, etc
|
63
|
-
Type: String
|
64
|
-
VolumeSize:
|
65
|
-
ConstraintDescription: must be between 5 and 1024 Gb.
|
66
|
-
Default: '<%= @volume_size %>'
|
67
|
-
Description: Size of Volume
|
68
|
-
MaxValue: '1024'
|
69
|
-
MinValue: '5'
|
70
|
-
Type: Number
|
71
|
-
Resources:
|
72
|
-
CfnUser:
|
73
|
-
Properties:
|
74
|
-
Path: "/"
|
75
|
-
Policies:
|
76
|
-
- PolicyDocument:
|
77
|
-
Statement:
|
78
|
-
- Action: cloudformation:DescribeStackResource
|
79
|
-
Effect: Allow
|
80
|
-
Resource: "*"
|
81
|
-
PolicyName: root
|
82
|
-
Type: AWS::IAM::User
|
83
|
-
DataVolume:
|
84
|
-
DeletionPolicy: Snapshot
|
85
|
-
Properties:
|
86
|
-
AvailabilityZone:
|
87
|
-
Fn::GetAtt:
|
88
|
-
- server
|
89
|
-
- AvailabilityZone
|
90
|
-
Size:
|
91
|
-
Ref: VolumeSize
|
92
|
-
Tags:
|
93
|
-
- Key: Usage
|
94
|
-
Value: Data Volume
|
95
|
-
Type: AWS::EC2::Volume
|
96
|
-
HostKeys:
|
97
|
-
Properties:
|
98
|
-
UserName:
|
99
|
-
Ref: CfnUser
|
100
|
-
Type: AWS::IAM::AccessKey
|
101
|
-
HostRecord:
|
102
|
-
Properties:
|
103
|
-
Comment: DNS name for my stack.
|
104
|
-
HostedZoneName: ".mydomain.net."
|
105
|
-
Name:
|
106
|
-
Fn::Join:
|
107
|
-
- ''
|
108
|
-
- - Ref: AWS::StackName
|
109
|
-
- ".mydomain.net."
|
110
|
-
ResourceRecords:
|
111
|
-
- Fn::GetAtt:
|
112
|
-
- server
|
113
|
-
- PublicDnsName
|
114
|
-
TTL: '60'
|
115
|
-
Type: CNAME
|
116
|
-
Type: AWS::Route53::RecordSet
|
117
|
-
MountPoint:
|
118
|
-
Properties:
|
119
|
-
Device: "/dev/sdf"
|
120
|
-
InstanceId:
|
121
|
-
Ref: server
|
122
|
-
VolumeId:
|
123
|
-
Ref: DataVolume
|
124
|
-
Type: AWS::EC2::VolumeAttachment
|
125
|
-
ServiceSecurityGroup:
|
126
|
-
Properties:
|
127
|
-
GroupDescription: Enable SSH access.
|
128
|
-
SecurityGroupIngress:
|
129
|
-
- CidrIp: 0.0.0.0/0
|
130
|
-
FromPort: '22'
|
131
|
-
IpProtocol: tcp
|
132
|
-
ToPort: '22'
|
133
|
-
Type: AWS::EC2::SecurityGroup
|
134
|
-
WaitCondition:
|
135
|
-
DependsOn: MountPoint
|
136
|
-
Metadata:
|
137
|
-
Comment1: Note that the WaitCondition is dependent on the volume mount point
|
138
|
-
allowing the volume to be created and attached to the EC2 instance
|
139
|
-
Comment2: The instance bootstrap script waits for the volume to be attached
|
140
|
-
to the instance prior to signalling completion.
|
141
|
-
Properties:
|
142
|
-
Handle:
|
143
|
-
Ref: WaitHandle
|
144
|
-
Timeout: '3000'
|
145
|
-
Type: AWS::CloudFormation::WaitCondition
|
146
|
-
WaitHandle:
|
147
|
-
Type: AWS::CloudFormation::WaitConditionHandle
|
148
|
-
<%= partial("server") %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
HostRecord:
|
2
|
-
Properties:
|
3
|
-
Comment: DNS name for <%= @domain %>
|
4
|
-
HostedZoneName: <%= @domain %>.
|
5
|
-
Name:
|
6
|
-
Fn::Join:
|
7
|
-
- ''
|
8
|
-
- - Ref: AWS::StackName
|
9
|
-
- ".<%= @domain %>"
|
10
|
-
ResourceRecords:
|
11
|
-
- !GetAtt elb.DNSName
|
12
|
-
TTL: '60'
|
13
|
-
Type: CNAME
|
14
|
-
Type: AWS::Route53::RecordSet
|
@@ -1,59 +0,0 @@
|
|
1
|
-
server:
|
2
|
-
Properties:
|
3
|
-
AvailabilityZone: us-east-1e
|
4
|
-
ImageId:
|
5
|
-
Ref: Ami
|
6
|
-
InstanceType:
|
7
|
-
Ref: InstanceType
|
8
|
-
KeyName:
|
9
|
-
Ref: KeyName
|
10
|
-
SecurityGroups:
|
11
|
-
- global
|
12
|
-
- Fn::Join:
|
13
|
-
- "-"
|
14
|
-
- - Ref: Environment
|
15
|
-
- Ref: Application
|
16
|
-
- Ref: ServiceSecurityGroup
|
17
|
-
UserData:
|
18
|
-
Fn::Base64: !Sub | # No more Fn::Join needed
|
19
|
-
#!/bin/bash -lexv
|
20
|
-
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
|
21
|
-
|
22
|
-
FIND_IN_MAP=!FindInMap [ MapName, TopLevelKey, SecondLevelKey ]
|
23
|
-
HOSTNAME_PREFIX=!FindInMap [ EnvironmentMapping, HostnamePrefix, !Ref Environment ]
|
24
|
-
BAR=!Ref DRINK ; MORE=!FindInMap [MapName, TopLevelKey, SecondLevelKey ]
|
25
|
-
|
26
|
-
BASE64=!Base64 "value to encode"
|
27
|
-
GET_ATT=!GetAtt server.PublicDnsName
|
28
|
-
GET_AZS=!GetAZs us-east-1
|
29
|
-
JOIN=!Join [ ":", [a, b, c]
|
30
|
-
SELECT=!Select [ "1", [ a, b, c] ]
|
31
|
-
|
32
|
-
VARTEST=<%= @vartest %>
|
33
|
-
|
34
|
-
echo !Ref AWS::StackName > /tmp/stack_name
|
35
|
-
# Helper function
|
36
|
-
function error_exit
|
37
|
-
{
|
38
|
-
/usr/local/bin/cfn-signal -e 1 -r "$1" '!Ref WaitHandle'
|
39
|
-
exit 1
|
40
|
-
}
|
41
|
-
# Wait for the EBS volume to show up
|
42
|
-
while [ ! -e /dev/xvdf ]; do echo Waiting for EBS volume to attach; sleep 1; done
|
43
|
-
/bin/mkdir /media/redis
|
44
|
-
/sbin/mkfs -t ext4 /dev/xvdf
|
45
|
-
echo "/dev/xvdf /media/redis auto defaults 0 0" >> /etc/fstab
|
46
|
-
/bin/mount /media/redis
|
47
|
-
/usr/bin/redis-cli shutdown
|
48
|
-
sleep 10
|
49
|
-
mv /var/lib/redis/* /media/redis/
|
50
|
-
rm -r /var/lib/redis
|
51
|
-
ln -s /media/redis /var/lib/redis
|
52
|
-
chown -R redis:redis /var/lib/redis
|
53
|
-
chown -R redis:redis /media/redis
|
54
|
-
/usr/bin/redis-server
|
55
|
-
# If all is well so signal success
|
56
|
-
/usr/local/bin/cfn-signal -e $? -r "Ready to rock" '!Ref WaitHandle'
|
57
|
-
cat /proc/uptime | cut -f1 -d'.' > /tmp/time-to-boot
|
58
|
-
|
59
|
-
Type: AWS::EC2::Instance
|
@@ -1,206 +0,0 @@
|
|
1
|
-
<% @app,@role,@env = name.sub('.yml','').split('-') -%>
|
2
|
-
---
|
3
|
-
AWSTemplateFormatVersion: '2010-09-09'
|
4
|
-
Description: <%= @app.capitalize %> Stack
|
5
|
-
Outputs:
|
6
|
-
ELBHostname:
|
7
|
-
Description: The URL of the website
|
8
|
-
Value:
|
9
|
-
Fn::Join:
|
10
|
-
- ''
|
11
|
-
- - http://
|
12
|
-
- Fn::GetAtt:
|
13
|
-
- elb
|
14
|
-
- DNSName
|
15
|
-
Parameters:
|
16
|
-
Ami:
|
17
|
-
Default: <%= @ami %>
|
18
|
-
Description: Ami id
|
19
|
-
Type: String
|
20
|
-
Application:
|
21
|
-
Default: <%= @app %>
|
22
|
-
Description: Application name
|
23
|
-
Type: String
|
24
|
-
Environment:
|
25
|
-
Default: <%= @env %>
|
26
|
-
Description: stag, prod etc
|
27
|
-
Type: String
|
28
|
-
InstanceType:
|
29
|
-
AllowedValues:
|
30
|
-
- t2.nano
|
31
|
-
- t2.micro
|
32
|
-
- t2.small
|
33
|
-
- t2.medium
|
34
|
-
- t2.large
|
35
|
-
- t2.xlarge
|
36
|
-
- t2.2xlarge
|
37
|
-
- m4.large
|
38
|
-
- m4.xlarge
|
39
|
-
- m4.2xlarge
|
40
|
-
- m4.4xlarge
|
41
|
-
- m4.10xlarge
|
42
|
-
- m4.16xlarge
|
43
|
-
- m3.medium
|
44
|
-
- m3.large
|
45
|
-
- m3.xlarge
|
46
|
-
- m3.2xlarge
|
47
|
-
- c4.large
|
48
|
-
- c4.xlarge
|
49
|
-
- c4.2xlarge
|
50
|
-
- c4.4xlarge
|
51
|
-
- c4.8xlarge
|
52
|
-
- c3.large
|
53
|
-
- c3.xlarge
|
54
|
-
- c3.2xlarge
|
55
|
-
- c3.4xlarge
|
56
|
-
- c3.8xlarge
|
57
|
-
ConstraintDescription: must be a valid EC2 instance type.
|
58
|
-
Default: <%= @instance_type %>
|
59
|
-
Description: WebServer EC2 instance type
|
60
|
-
Type: String
|
61
|
-
KeyName:
|
62
|
-
Default: default
|
63
|
-
Description: The EC2 Key Pair to allow SSH access to the instances
|
64
|
-
Type: String
|
65
|
-
Role:
|
66
|
-
Default: <%= @role %>
|
67
|
-
Description: redis, psql, app, etc
|
68
|
-
Type: String
|
69
|
-
WebServerPort:
|
70
|
-
Default: '<%= @port %>'
|
71
|
-
Description: The TCP port for the Web Server
|
72
|
-
Type: Number
|
73
|
-
Resources:
|
74
|
-
CPUAlarmHigh:
|
75
|
-
Properties:
|
76
|
-
AlarmActions:
|
77
|
-
- Ref: WebServerScaleUpPolicy
|
78
|
-
AlarmDescription: Scale-up if CPU > <%= @high_threshold %>% for <%= @high_mins %>
|
79
|
-
ComparisonOperator: GreaterThanThreshold
|
80
|
-
Dimensions:
|
81
|
-
- Name: AutoScalingGroupName
|
82
|
-
Value:
|
83
|
-
Ref: WebServerGroup
|
84
|
-
EvaluationPeriods: '<%= @high_periods %>'
|
85
|
-
MetricName: CPUUtilization
|
86
|
-
Namespace: AWS/EC2
|
87
|
-
Period: '60'
|
88
|
-
Statistic: Average
|
89
|
-
Threshold: '<%= @high_threshold %>'
|
90
|
-
Type: AWS::CloudWatch::Alarm
|
91
|
-
CPUAlarmLow:
|
92
|
-
Properties:
|
93
|
-
AlarmActions:
|
94
|
-
- Ref: WebServerScaleDownPolicy
|
95
|
-
AlarmDescription: Scale-down if CPU < <%= @low_threshold %>% for 10 minutes
|
96
|
-
ComparisonOperator: LessThanThreshold
|
97
|
-
Dimensions:
|
98
|
-
- Name: AutoScalingGroupName
|
99
|
-
Value:
|
100
|
-
Ref: WebServerGroup
|
101
|
-
EvaluationPeriods: '<%= @low_periods %>'
|
102
|
-
MetricName: CPUUtilization
|
103
|
-
Namespace: AWS/EC2
|
104
|
-
Period: '60'
|
105
|
-
Statistic: Average
|
106
|
-
Threshold: '<%= @low_threshold %>'
|
107
|
-
Type: AWS::CloudWatch::Alarm
|
108
|
-
<%= partial("host_record", domain: "mydomain.net") %>
|
109
|
-
LaunchConfig:
|
110
|
-
Properties:
|
111
|
-
BlockDeviceMappings:
|
112
|
-
- DeviceName: "/dev/sdb"
|
113
|
-
VirtualName: ephemeral0
|
114
|
-
ImageId: !Ref Ami
|
115
|
-
InstanceType: !Ref InstanceType
|
116
|
-
KeyName:
|
117
|
-
Ref: KeyName
|
118
|
-
SecurityGroups:
|
119
|
-
- global
|
120
|
-
- Fn::Join:
|
121
|
-
- "-"
|
122
|
-
- - Ref: Application
|
123
|
-
- Ref: Environment
|
124
|
-
- Ref: ServiceSecurityGroup
|
125
|
-
UserData:
|
126
|
-
Fn::Base64: !Sub | # No more Fn::Join needed
|
127
|
-
<%= partial("user_data/bootstrap.sh", {}, indent: 10) %>
|
128
|
-
Type: AWS::AutoScaling::LaunchConfiguration
|
129
|
-
ServiceSecurityGroup:
|
130
|
-
Properties:
|
131
|
-
GroupDescription: Enable SSH access and HTTP from the load balancer only
|
132
|
-
SecurityGroupIngress:
|
133
|
-
- CidrIp: 0.0.0.0/0
|
134
|
-
FromPort: '22'
|
135
|
-
IpProtocol: tcp
|
136
|
-
ToPort: '22'
|
137
|
-
- FromPort:
|
138
|
-
Ref: WebServerPort
|
139
|
-
IpProtocol: tcp
|
140
|
-
SourceSecurityGroupName:
|
141
|
-
Fn::GetAtt:
|
142
|
-
- elb
|
143
|
-
- SourceSecurityGroup.GroupName
|
144
|
-
SourceSecurityGroupOwnerId:
|
145
|
-
Fn::GetAtt:
|
146
|
-
- elb
|
147
|
-
- SourceSecurityGroup.OwnerAlias
|
148
|
-
ToPort:
|
149
|
-
Ref: WebServerPort
|
150
|
-
Type: AWS::EC2::SecurityGroup
|
151
|
-
WebServerGroup:
|
152
|
-
Properties:
|
153
|
-
AvailabilityZones: !GetAZs ""
|
154
|
-
HealthCheckGracePeriod: '300'
|
155
|
-
HealthCheckType: ELB
|
156
|
-
LaunchConfigurationName:
|
157
|
-
Ref: LaunchConfig
|
158
|
-
LoadBalancerNames:
|
159
|
-
- Ref: elb
|
160
|
-
MaxSize: '<%= @max_size %>'
|
161
|
-
MinSize: '<%= @min_size %>'
|
162
|
-
Type: AWS::AutoScaling::AutoScalingGroup
|
163
|
-
WebServerScaleDownPolicy:
|
164
|
-
Properties:
|
165
|
-
AdjustmentType: ChangeInCapacity
|
166
|
-
AutoScalingGroupName:
|
167
|
-
Ref: WebServerGroup
|
168
|
-
Cooldown: '120'
|
169
|
-
ScalingAdjustment: "<%= @down_adjustment %>"
|
170
|
-
Type: AWS::AutoScaling::ScalingPolicy
|
171
|
-
WebServerScaleUpPolicy:
|
172
|
-
Properties:
|
173
|
-
AdjustmentType: ChangeInCapacity
|
174
|
-
AutoScalingGroupName:
|
175
|
-
Ref: WebServerGroup
|
176
|
-
Cooldown: '120'
|
177
|
-
ScalingAdjustment: '<%= @up_adjustment %>'
|
178
|
-
Type: AWS::AutoScaling::ScalingPolicy
|
179
|
-
elb:
|
180
|
-
Properties:
|
181
|
-
AvailabilityZones: !GetAZs ""
|
182
|
-
HealthCheck:
|
183
|
-
HealthyThreshold: '3'
|
184
|
-
Interval: '6'
|
185
|
-
Target:
|
186
|
-
Fn::Join:
|
187
|
-
- ''
|
188
|
-
- - 'HTTP:'
|
189
|
-
- Ref: WebServerPort
|
190
|
-
- "/up/elb"
|
191
|
-
Timeout: '5'
|
192
|
-
UnhealthyThreshold: '5'
|
193
|
-
Listeners:
|
194
|
-
- InstancePort:
|
195
|
-
Ref: WebServerPort
|
196
|
-
LoadBalancerPort: '80'
|
197
|
-
Protocol: HTTP
|
198
|
-
<% if @ssl_cert %>
|
199
|
-
- InstancePort:
|
200
|
-
Ref: WebServerPort
|
201
|
-
LoadBalancerPort: '443'
|
202
|
-
PolicyNames: []
|
203
|
-
Protocol: HTTPS
|
204
|
-
SSLCertificateId: '<%= @ssl_cert %>'
|
205
|
-
<% end %>
|
206
|
-
Type: AWS::ElasticLoadBalancing::LoadBalancer
|