/
graphite.json
683 lines (639 loc) · 27 KB
/
graphite.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Launches a Graphite stack",
"Parameters" : {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "m1.small",
"AllowedValues" : ["m1.small","m1.medium","m1.large","m1.xlarge","m3.medium","m3.large","m3.xlarge","m3.2xlarge","c1.medium","c1.xlarge","c3.large","c3.xlarge","c3.2xlarge","c3.4xlarge","c3.8xlarge","cc2.8xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","r3.large","r3.xlarge","r3.2xlarge","r3.4xlarge","r3.8xlarge","cr1.8xlarge","hi1.4xlarge","hs1.8xlarge","i2.xlarge","i2.2xlarge","i2.4xlarge","i2.8xlarge","t1.micro","cg1.4xlarge","g2.2xlarge"],
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String"
},
"GraphiteTimeZone" : {
"Description" : "Your local time zone (used for graph rendering, not for metrics storage)",
"Type" : "String",
"Default" : "America/Los_Angeles"
},
"GraphiteUsername" : {
"Description" : "Graphite superuser username",
"Type" : "String",
"Default" : "graphite"
},
"GraphitePassword" : {
"Description" : "Graphite superuser password",
"Type" : "String",
"Default" : "graphite"
},
"GraphiteEmail" : {
"Description" : "Graphite superuser email",
"Type" : "String"
},
"GraphiteSecretKey" : {
"Description" : "String for Graphite to use when salting hashes. Make it long and unique. Changing it later will probably break login.",
"Type" : "String",
"Default" : "some_very_salty_salt"
},
"GraphiteEbsSnapshot" : {
"Description" : "Latest EBS snapshot of Graphite data volume (e.g., 'snap-1234567b')",
"Type" : "String"
},
"ElasticsearchDockerImage" : {
"Description" : "Path to the Elasticsearch image to use (format: '[<registry>[:<port>]/]<repository>[:<version>]')",
"Type" : "String",
"Default" : "dockerfile/elasticsearch"
},
"Subnets" : {
"Description" : "List of VPC subnet IDs for the cluster. Note: must match the passed AvailabilityZones.",
"Type" : "CommaDelimitedList"
},
"VpcId" : {
"Description" : "VPC associated with the provided subnets",
"Type" : "String"
},
"AdminSecurityGroup" : {
"Description" : "Existing security group that should be granted administrative access (e.g., 'sg-123456')",
"Type" : "String"
},
"AvailabilityZones": {
"Description" : "(Optional) If passed, only launch nodes in these AZs (e.g., 'us-east-1a,us-east-1b'). Note: these must match the passed Subnets.",
"Type" : "CommaDelimitedList",
"Default" : ""
}
},
"Conditions" : {
"UseAllAvailabilityZones" : {"Fn::Equals" : [{ "Fn::Join" : ["", {"Ref" : "AvailabilityZones"} ]}, ""]}
},
"Mappings" : {
"RegionMap" : {
"us-east-1" : {
"AMI" : "ami-f40bbe9c"
},
"us-west-1" : {
"AMI" : "ami-cfe2ea8a"
},
"us-west-2" : {
"AMI" : "ami-3fb1f20f"
},
"eu-west-1" : {
"AMI" : "ami-e0d27397"
},
"ap-southeast-1" : {
"AMI" : "ami-8a7057d8"
},
"ap-southeast-2" : {
"AMI" : "ami-d5c1a2ef"
},
"ap-northeast-1" : {
"AMI" : "ami-a7def7a6"
},
"sa-east-1" : {
"AMI" : "ami-070fa51a"
}
}
},
"Resources" : {
"IAMUser" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Policies" : [{
"PolicyName" : "IAMAccess",
"PolicyDocument" : {
"Statement" : [{
"Effect" : "Allow",
"NotAction" : "iam:*",
"Resource" : "*"
}]
}
}]
}
},
"HostKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : { "Ref" : "IAMUser" }
}
},
"ServerGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : {
"Fn::If" : [
"UseAllAvailabilityZones",
{ "Fn::GetAZs": "" },
{"Ref" : "AvailabilityZones"}
]
},
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
"MinSize" : 1,
"MaxSize" : 1,
"DesiredCapacity" : 1,
"LoadBalancerNames" : [ { "Ref" : "PublicElb" }, { "Ref" : "PrivateElb" } ],
"VPCZoneIdentifier" : { "Ref" : "Subnets" }
}
},
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config": {
"packages" : {
"python": {
"boto": []
},
"apt" : {
"graphite-web" : [],
"graphite-carbon" : [],
"apache2" : [],
"libapache2-mod-wsgi" : [],
"expect": []
}
},
"files" : {
"/etc/graphite/local_settings.py" : {
"content" : { "Fn::Join" : ["\n", [
"LOG_RENDERING_PERFORMANCE = True",
"LOG_CACHE_PERFORMANCE = True",
"LOG_METRIC_ACCESS = True",
"GRAPHITE_ROOT = '/usr/share/graphite-web'",
"CONF_DIR = '/etc/graphite'",
"STORAGE_DIR = '/var/lib/graphite/whisper'",
"CONTENT_DIR = '/usr/share/graphite-web/static'",
"WHISPER_DIR = '/var/lib/graphite/whisper'",
"LOG_DIR = '/var/log/graphite'",
"INDEX_FILE = '/var/lib/graphite/search_index' # Search index file",
"DATABASES = {",
" 'default': {",
" 'NAME': '/var/lib/graphite/graphite.db',",
" 'ENGINE': 'django.db.backends.sqlite3',",
" 'USER': '',",
" 'PASSWORD': '',",
" 'HOST': '',",
" 'PORT': ''",
" }",
"}",
"USE_REMOTE_USER_AUTHENTICATION = True",
"TIME_ZONE = '{{ time_zone }}'",
"SECRET_KEY = '{{ secret_key }}'",
""
]]},
"context" : {
"time_zone": { "Ref" : "GraphiteTimeZone" },
"secret_key": { "Ref" : "GraphiteSecretKey" }
},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/etc/default/graphite-carbon" : {
"content" : { "Fn::Join" : ["\n", [
"CARBON_CACHE_ENABLED=true", ""
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/etc/carbon/storage-schemas.conf" : {
"content" : { "Fn::Join" : ["\n", [
"[carbon]",
"pattern = ^carbon\\.",
"retentions = 60:90d",
"",
"[default]",
"pattern = .*",
"retentions = 60s:1d,5m:1w,15m:1y,1h:10y",
""
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/etc/carbon/carbon.conf": {
"content" : { "Fn::Join" : ["\n", [
"[cache]",
"STORAGE_DIR = /var/lib/graphite/",
"CONF_DIR = /etc/carbon/",
"LOG_DIR = /var/log/carbon/",
"PID_DIR = /var/run/",
"LOCAL_DATA_DIR = /var/lib/graphite/whisper/",
"ENABLE_LOGROTATION = True",
"USER = _graphite",
"MAX_CACHE_SIZE = inf",
"MAX_UPDATES_PER_SECOND = 500",
"MAX_CREATES_PER_MINUTE = 50",
"LINE_RECEIVER_INTERFACE = 0.0.0.0",
"LINE_RECEIVER_PORT = 2003",
"ENABLE_UDP_LISTENER = False",
"UDP_RECEIVER_INTERFACE = 0.0.0.0",
"UDP_RECEIVER_PORT = 2003",
"PICKLE_RECEIVER_INTERFACE = 0.0.0.0",
"PICKLE_RECEIVER_PORT = 2004",
"LOG_LISTENER_CONNECTIONS = True",
"USE_INSECURE_UNPICKLER = False",
"CACHE_QUERY_INTERFACE = 0.0.0.0",
"CACHE_QUERY_PORT = 7002",
"USE_FLOW_CONTROL = True",
"LOG_UPDATES = False",
"LOG_CACHE_HITS = False",
"LOG_CACHE_QUEUE_SORTS = True",
"CACHE_WRITE_STRATEGY = sorted",
"WHISPER_AUTOFLUSH = False",
"WHISPER_FALLOCATE_CREATE = True",
"",
"[relay]",
"LINE_RECEIVER_INTERFACE = 0.0.0.0",
"LINE_RECEIVER_PORT = 2013",
"PICKLE_RECEIVER_INTERFACE = 0.0.0.0",
"PICKLE_RECEIVER_PORT = 2014",
"LOG_LISTENER_CONNECTIONS = True",
"RELAY_METHOD = rules",
"REPLICATION_FACTOR = 1",
"DESTINATIONS = 127.0.0.1:2004",
"MAX_DATAPOINTS_PER_MESSAGE = 500",
"MAX_QUEUE_SIZE = 10000",
"USE_FLOW_CONTROL = True",
"",
"[aggregator]",
"LINE_RECEIVER_INTERFACE = 0.0.0.0",
"LINE_RECEIVER_PORT = 2023",
"PICKLE_RECEIVER_INTERFACE = 0.0.0.0",
"PICKLE_RECEIVER_PORT = 2024",
"LOG_LISTENER_CONNECTIONS = True",
"FORWARD_ALL = True",
"DESTINATIONS = 127.0.0.1:2004",
"REPLICATION_FACTOR = 1",
"MAX_QUEUE_SIZE = 10000",
"USE_FLOW_CONTROL = True",
"MAX_DATAPOINTS_PER_MESSAGE = 500",
"MAX_AGGREGATION_INTERVALS = 5",
""
]]},
"mode" : "000755",
"owner" : "root",
"group" : "root"
},
"/usr/local/bin/manage-snapshots" : {
"content" : { "Fn::Join" : ["\n", [
"#!/usr/bin/env python",
"import argparse",
"import boto.cloudformation",
"import boto.ec2",
"",
"",
"class SnapshotManager(object):",
" STACK_PARAM = 'GraphiteEbsSnapshot'",
" ",
" def __init__(self, region, stack, volume, aws_access_key_id=None, aws_secret_access_key=None):",
" self.region = region",
" self.stack = stack",
" self.volume = volume",
" if aws_access_key_id and aws_secret_access_key:",
" self.ec2_conn = boto.ec2.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)",
" self.cfn_conn = boto.cloudformation.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)",
" else:",
" self.ec2_conn = boto.ec2.connect_to_region(region)",
" self.cfn_conn = boto.cloudformation.connect_to_region(region)",
" ",
" def create_snapshot(self):",
" print 'Creating snapshot for volume {volume}'.format(volume=self.volume)",
" description = 'Created from {volume} for stack {stack}'.format(volume=self.volume, stack=self.stack)",
" return self.ec2_conn.create_snapshot(self.volume, description)",
" ",
" def get_completed_snapshots(self):",
" return sorted([s for s in self.ec2_conn.get_all_snapshots(filters={'volume-id': self.volume}) if s.status=='completed'], key=lambda s: s.start_time)",
" ",
" def update_stack_snapshot(self, snapshot):",
" print 'Updating {param} on stack {stack} to {snap}'.format(param=self.STACK_PARAM, stack=self.stack, snap=snapshot)",
" params = [(p.key, p.value) for p in self.cfn_conn.describe_stacks(self.stack)[0].parameters if p.key != self.STACK_PARAM]",
" params.append((self.STACK_PARAM, snapshot))",
" template = self.cfn_conn.get_template(self.stack)['GetTemplateResponse']['GetTemplateResult']['TemplateBody']",
" self.cfn_conn.update_stack(self.stack, template_body=template, parameters=params, capabilities=['CAPABILITY_IAM'])",
" ",
" def trim_snapshots(self, keep=5):",
" for snapshot in self.get_completed_snapshots()[:-keep]:",
" print 'Deleting snapshot {snap}'.format(snap=snapshot.id)",
" self.ec2_conn.delete_snapshot(snapshot.id)",
"",
"",
"def main():",
" parser = argparse.ArgumentParser()",
" parser.add_argument('command', metavar='COMMAND', help='command', choices=['create', 'update-stack', 'trim'])",
" parser.add_argument('-v', dest='volume', help='EBS volume id', required=True)",
" parser.add_argument('-s', dest='stack', help='CloudFormation stack ID or name', required=True)",
" parser.add_argument('-r', dest='region', help='AWS Region', required=True)",
" parser.add_argument('-m', dest='max', help='Max number of snapshots to keep when trimming', default=5, type=int)",
" parser.add_argument('--key-id', dest='key_id', help='AWS access key id')",
" parser.add_argument('--secret-key', dest='secret_key', help='AWS secret access key')",
" args = parser.parse_args()",
" ",
" sm = SnapshotManager(args.region, args.stack, args.volume, args.key_id, args.secret_key)",
" if args.command == 'create':",
" sm.create_snapshot()",
" elif args.command == 'update-stack':",
" snapshots = sm.get_completed_snapshots()",
" sm.update_stack_snapshot(snapshots[-1].id)",
" elif args.command == 'trim':",
" sm.trim_snapshots(args.max)",
" ",
"",
"if __name__ == '__main__':",
" main()",
""
]]},
"mode" : "000755",
"owner" : "root",
"group" : "root"
},
"/usr/local/bin/get-attached-volume" : {
"content" : { "Fn::Join" : ["\n", [
"#!/usr/bin/env python",
"import boto.ec2",
"import boto.utils",
"",
"c = boto.ec2.connect_to_region('{{region}}', aws_access_key_id='{{aws_key}}', aws_secret_access_key='{{aws_secret}}')",
"instance_id = boto.utils.get_instance_metadata()['instance-id']",
"volume_id = c.get_all_volumes(filters={'attachment.instance-id': instance_id, 'attachment.device': '{{device}}'})[0].id",
"print volume_id"
]]},
"context" : {
"region": { "Ref" : "AWS::Region" },
"aws_key": { "Ref" : "HostKeys" },
"aws_secret": { "Fn::GetAtt" : ["HostKeys", "SecretAccessKey"]},
"device": "/dev/xvdf"
},
"mode" : "000755",
"owner" : "root",
"group" : "root"
},
"/etc/cron.d/snapshots": {
"content" : { "Fn::Join" : ["\n", [
"# Update stack so new instances boot from latest snapshot",
"COMMON_OPTS=\"-s {{stack}} -r {{region}} --key-id {{key}} --secret-key {{secret}}\"",
"23 * * * * root /usr/local/bin/manage-snapshots create -v `/usr/local/bin/get-attached-volume` $COMMON_OPTS",
"28 * * * * root /usr/local/bin/manage-snapshots trim -v `/usr/local/bin/get-attached-volume` -m 5 $COMMON_OPTS",
"* * * * * root /usr/local/bin/manage-snapshots update-stack -v `/usr/local/bin/get-attached-volume` $COMMON_OPTS",
""
]]},
"context" : {
"region": { "Ref" : "AWS::Region" },
"stack": { "Ref" : "AWS::StackName" },
"key": { "Ref" : "HostKeys" },
"secret": { "Fn::GetAtt" : ["HostKeys", "SecretAccessKey"]}
},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/var/lib/graphite/elasticsearch/elasticsearch.yml" : {
"content" : { "Fn::Join" : ["\n", [
"path:",
" logs: /data/log",
" data: /data/data",
""
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/etc/apache2/sites-available/grafana.conf" : {
"content" : { "Fn::Join" : ["\n", [
"Header set Access-Control-Allow-Origin \"*\"",
"Header set Access-Control-Allow-Methods \"GET, OPTIONS\"",
"Header set Access-Control-Allow-Headers \"origin, authorization, accept\"",
"alias /grafana /usr/share/grafana",
""
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
}
}
}
}
},
"Properties" : {
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI"] },
"SecurityGroups" : [ { "Ref" : "ServerSecurityGroup" }, { "Ref" : "AdminSecurityGroup" } ],
"AssociatePublicIpAddress": "true",
"InstanceType" : { "Ref" : "InstanceType" },
"BlockDeviceMappings" : [ {
"DeviceName" : "/dev/xvdf",
"Ebs" : {
"DeleteOnTermination" : true,
"SnapshotId" : { "Ref" : "GraphiteEbsSnapshot" },
"VolumeType" : "gp2"
}
}],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -ex\n",
"# Helper function\n",
"function error_exit\n",
"{\n",
" cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
" exit 1\n",
"}\n",
"# Mount volume created from latest graphite snapshot\n",
"mkdir -p /var/lib/graphite\n",
"mount /dev/xvdf /var/lib/graphite\n",
"# Set up grafana and elasticsearch directories\n",
"mkdir -p /var/lib/graphite/elasticsearch\n",
"mkdir -p /usr/share/grafana\n",
"apt-get update\n",
"cfn-init -s ", { "Ref" : "AWS::StackName" }, " -r LaunchConfig ",
" --access-key ", { "Ref" : "HostKeys" },
" --secret-key ", { "Fn::GetAtt": ["HostKeys", "SecretAccessKey"] },
" --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n",
"graphite-manage syncdb --noinput\n",
"chown _graphite:_graphite /var/lib/graphite/graphite.db\n",
"# Set admin password\n",
"USERNAME=", { "Ref" : "GraphiteUsername" }, "\n",
"PASSWORD=", { "Ref" : "GraphitePassword" }, "\n",
"EMAIL=", { "Ref" : "GraphiteEmail" }, "\n",
"# Ignore errors on create since user might already exist\n",
"graphite-manage createsuperuser --username=\"${USERNAME}\" --email=\"${EMAIL}\" --noinput || true\n",
"expect << DONE\n",
" spawn graphite-manage changepassword \"${USERNAME}\"\n",
" expect \"Password: \"\n",
" send -- \"${PASSWORD}\\r\"\n",
" expect \"Password (again): \"\n",
" send -- \"${PASSWORD}\\r\"\n",
" expect eof\n",
"DONE\n",
"a2dissite 000-default\n",
"cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available\n",
"a2ensite apache2-graphite\n",
"service apache2 reload\n",
"service carbon-cache start\n",
"# Set up Elasticsearch\n",
"docker pull ", { "Ref": "ElasticsearchDockerImage" }, "\n",
"runit-service create elasticsearch docker run --rm",
" -p 9200:9200",
" -p 9300:9300",
" -v /var/lib/graphite/elasticsearch:/data",
" ", { "Ref" : "ElasticsearchDockerImage"}, " ",
" /elasticsearch/bin/elasticsearch",
" -Des.config=/data/elasticsearch.yml",
"|| error_exit 'Failed to launch Docker container'\n",
"runit-service enable elasticsearch\n",
"# Set up Grafana\n",
"curl -O -L http://grafanarel.s3.amazonaws.com/grafana-1.7.0.tar.gz\n",
"tar xzf grafana-1.7.0.tar.gz -C /usr/share/grafana --strip=1\n",
"a2ensite grafana\n",
"a2enmod headers # For CORS needed by Grafana \n",
"service apache2 restart\n",
"# Must use this server's public hostname because graphite.url needs to be accessible by both this server and the browser\n",
"# Consequently, can't do this via via CloudFormation::Init\n",
"cat << EOF > /usr/share/grafana/config.js \n",
"define(['settings'],\n",
"function (Settings) {\n",
" return new Settings({\n",
" datasources: {\n",
" graphite: {\n",
" type: 'graphite',\n",
" url: 'http://`ec2metadata --public-hostname`',\n",
" },\n",
" elasticsearch: {\n",
" type: 'elasticsearch',\n",
" url: 'http://`ec2metadata --public-hostname`:9200',\n",
" index: 'grafana-dash',\n",
" grafanaDB: true,\n",
" }\n",
" },\n",
" search: {\n",
" max_results: 20\n",
" },\n",
" default_route: '/dashboard/file/default.json',\n",
" unsaved_changes_warning: true,\n",
" playlist_timespan: '1m',\n",
" admin: {\n",
" password: ''\n",
" },\n",
" plugins: {\n",
" panels: []\n",
" }\n",
" });\n",
"});\n",
"EOF\n",
"# All is well so signal success\n",
"cfn-signal -e 0 -r \"Stack setup complete\" '", { "Ref" : "WaitHandle" }, "'\n",
"#EOF"
]]}}
}
},
"PublicLbSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Allow access to Graphite",
"VpcId" : { "Ref" : "VpcId" },
"SecurityGroupIngress" : []
}
},
"PrivateLbSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Allow access to Graphite",
"VpcId" : { "Ref" : "VpcId" },
"SecurityGroupIngress" : [
{ "IpProtocol" : "tcp", "FromPort" : "2003", "ToPort" : "2003", "SourceSecurityGroupId" : { "Ref" : "ClientSecurityGroup"} }
]
}
},
"ClientSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "For Graphite clients. Grants access to carbon.",
"VpcId" : { "Ref" : "VpcId" }
}
},
"ServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Graphite servers",
"VpcId" : { "Ref" : "VpcId" },
"SecurityGroupIngress" : [
{ "IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "SourceSecurityGroupId" : { "Ref" : "PublicLbSecurityGroup"} },
{ "IpProtocol" : "tcp", "FromPort" : "2003", "ToPort" : "2003", "SourceSecurityGroupId" : { "Ref" : "PublicLbSecurityGroup"} },
{ "IpProtocol" : "tcp", "FromPort" : "2003", "ToPort" : "2003", "SourceSecurityGroupId" : { "Ref" : "PrivateLbSecurityGroup"} },
{ "IpProtocol" : "tcp", "FromPort" : "2003", "ToPort" : "2003", "SourceSecurityGroupId" : { "Ref" : "ClientSecurityGroup"} }
]
}
},
"PublicElb" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"SecurityGroups": [{ "Ref": "PublicLbSecurityGroup" }, { "Ref" : "AdminSecurityGroup" }],
"Subnets": { "Ref": "Subnets" },
"Listeners" : [
{
"LoadBalancerPort" : "80",
"Protocol" : "HTTP",
"InstancePort" : "80",
"InstanceProtocol" : "HTTP"
},
{
"LoadBalancerPort" : "2003",
"Protocol" : "TCP",
"InstancePort" : "2003",
"InstanceProtocol" : "TCP"
},
{
"LoadBalancerPort" : "9200",
"Protocol" : "HTTP",
"InstancePort" : "9200",
"InstanceProtocol" : "HTTP"
}
],
"HealthCheck": {
"Target": "HTTP:80/",
"HealthyThreshold": "2",
"UnhealthyThreshold": "3",
"Interval": "30",
"Timeout": "5"
}
}
},
"PrivateElb" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"Scheme" : "internal",
"SecurityGroups": [{ "Ref": "PrivateLbSecurityGroup" }],
"Subnets": { "Ref": "Subnets" },
"Listeners" : [
{
"LoadBalancerPort" : "2003",
"Protocol" : "TCP",
"InstancePort" : "2003",
"InstanceProtocol" : "TCP"
}
],
"HealthCheck": {
"Target": "TCP:2003",
"HealthyThreshold": "2",
"UnhealthyThreshold": "3",
"Interval": "30",
"Timeout": "5"
}
}
},
"WaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
}
},
"Outputs" : {
"PublicEndpoint" : {
"Description" : "Public endpoint",
"Value" : { "Fn::GetAtt" : [ "PublicElb", "DNSName" ] }
},
"PrivateEndpoint" : {
"Description" : "Private endpoint",
"Value" : { "Fn::GetAtt" : [ "PrivateElb", "DNSName" ] }
},
"ClientSecurityGroup" : {
"Value" : { "Ref" : "ClientSecurityGroup" }
}
}
}