This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1081 lines (874 loc) · 45.3 KB
/
index.html
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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>README</title>
<style type="text/css">
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
margin-top: 0 !important; }
body > *:last-child {
margin-bottom: 0 !important; }
a {
color: #4183C4; }
a.absent {
color: #cc0000; }
a.anchor {
display: block;
padding-left: 30px;
margin-left: -30px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0; }
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA09pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoMTMuMCAyMDEyMDMwNS5tLjQxNSAyMDEyLzAzLzA1OjIxOjAwOjAwKSAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUM2NjlDQjI4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUM2NjlDQjM4ODBGMTFFMTg1ODlEODNERDJBRjUwQTQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5QzY2OUNCMDg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5QzY2OUNCMTg4MEYxMUUxODU4OUQ4M0REMkFGNTBBNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsQhXeAAAABfSURBVHjaYvz//z8DJYCRUgMYQAbAMBQIAvEqkBQWXI6sHqwHiwG70TTBxGaiWwjCTGgOUgJiF1J8wMRAIUA34B4Q76HUBelAfJYSA0CuMIEaRP8wGIkGMA54bgQIMACAmkXJi0hKJQAAAABJRU5ErkJggg==) no-repeat 10px center;
text-decoration: none; }
h1 tt, h1 code {
font-size: inherit; }
h2 tt, h2 code {
font-size: inherit; }
h3 tt, h3 code {
font-size: inherit; }
h4 tt, h4 code {
font-size: inherit; }
h5 tt, h5 code {
font-size: inherit; }
h6 tt, h6 code {
font-size: inherit; }
h1 {
font-size: 28px;
color: black; }
h2 {
font-size: 24px;
border-bottom: 1px solid #cccccc;
color: black; }
h3 {
font-size: 18px; }
h4 {
font-size: 16px; }
h5 {
font-size: 14px; }
h6 {
color: #777777;
font-size: 14px; }
p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0; }
hr {
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC) repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
padding: 0;
}
body > h2:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child + h2 {
margin-top: 0;
padding-top: 0; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
margin-top: 0;
padding-top: 0; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
margin-top: 0; }
li p.first {
display: inline-block; }
li {
margin: 0; }
ul, ol {
padding-left: 30px; }
ul :first-child, ol :first-child {
margin-top: 0; }
dl {
padding: 0; }
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px; }
dl dt:first-child {
padding: 0; }
dl dt > :first-child {
margin-top: 0; }
dl dt > :last-child {
margin-bottom: 0; }
dl dd {
margin: 0 0 15px;
padding: 0 15px; }
dl dd > :first-child {
margin-top: 0; }
dl dd > :last-child {
margin-bottom: 0; }
blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
table {
padding: 0;border-collapse: collapse; }
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
table tr:nth-child(2n) {
background-color: #f8f8f8; }
table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr th :first-child, table tr td :first-child {
margin-top: 0; }
table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
img {
max-width: 100%; }
span.frame {
display: block;
overflow: hidden; }
span.frame > span {
border: 1px solid #dddddd;
display: block;
float: left;
overflow: hidden;
margin: 13px 0 0;
padding: 7px;
width: auto; }
span.frame span img {
display: block;
float: left; }
span.frame span span {
clear: both;
color: #333333;
display: block;
padding: 5px 0 0; }
span.align-center {
display: block;
overflow: hidden;
clear: both; }
span.align-center > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: center; }
span.align-center span img {
margin: 0 auto;
text-align: center; }
span.align-right {
display: block;
overflow: hidden;
clear: both; }
span.align-right > span {
display: block;
overflow: hidden;
margin: 13px 0 0;
text-align: right; }
span.align-right span img {
margin: 0;
text-align: right; }
span.float-left {
display: block;
margin-right: 13px;
overflow: hidden;
float: left; }
span.float-left span {
margin: 13px 0 0; }
span.float-right {
display: block;
margin-left: 13px;
overflow: hidden;
float: right; }
span.float-right > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: right; }
code, tt {
margin: 0 2px;
padding: 0 5px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px; }
pre code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent; }
.highlight pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre code, pre tt {
background-color: transparent;
border: none; }
sup {
font-size: 0.83em;
vertical-align: super;
line-height: 0;
}
kbd {
display: inline-block;
padding: 3px 5px;
font-size: 11px;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb
}
* {
-webkit-print-color-adjust: exact;
}
@media screen and (min-width: 914px) {
body {
width: 854px;
margin:0 auto;
}
}
@media print {
table, pre {
page-break-inside: avoid;
}
pre {
word-wrap: break-word;
}
}
</style>
<style type="text/css">
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
</style>
<style type="text/css">
pre.line-numbers {
position: relative;
padding-left: 3.8em;
counter-reset: linenumber;
}
pre.line-numbers > code {
position: relative;
}
.line-numbers .line-numbers-rows {
position: absolute;
pointer-events: none;
top: 0;
font-size: 100%;
left: -3.8em;
width: 3em; /* works for line-numbers below 1000 lines */
letter-spacing: -1px;
border-right: 1px solid #999;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.line-numbers-rows > span {
pointer-events: none;
display: block;
counter-increment: linenumber;
}
.line-numbers-rows > span:before {
content: counter(linenumber);
color: #999;
display: block;
padding-right: 0.8em;
text-align: right;
}
</style>
</head>
<body>
<h1 id="toc_0">Cloud Computing with AWS</h1>
<p><strong>Jonatan Landsberg</strong>, [email protected]<br>
<strong>David Strömberg</strong>, [email protected] </p>
<ol>
<li><a href="#setup">Project setup</a></li>
<li><a href="#ec2deploy">Deploy on EC2</a></li>
<li><a href="#database">Connecting your application to a RDS instance</a></li>
<li><a href="#CodePipeline1">Code Pipeline Preparations</a></li>
<li><a href="#CodePipeline2">Create the CodePipeline</a></li>
<li><a href="#Balancer">Load balancing with Elastic Load Balancer</a></li>
<li><a href="#Route53">Subdomain with Route53</a></li>
<li><a href="#less">Labs with less instructions</a></li>
</ol>
<p><a name="setup"></a></p>
<h2 id="toc_1">1. Project setup</h2>
<h3 id="toc_2">Installation</h3>
<ol>
<li>Install <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java 8</a></li>
<li>Install <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git</a></li>
<li>Install <a href="https://www.postgresql.org/ftp/pgadmin/pgadmin4/v2.0/">PgAdmin</a><br></li>
</ol>
<h3 id="toc_3">Verify local environment</h3>
<ol>
<li>Create a new <a href="https://github.com/Omegapoint/">Git repository</a> called <code><application-name></code></li>
<li>Clone the template repository <code>$ git clone --bare https://github.com/Omegapoint/cloud-computing-app.git</code></li>
<li><code>$ cd cloud-computing-app.git</code></li>
<li><code>$ git push --mirror https://github.com/Omegapoint/<application-name>.git</code></li>
<li><code>$ cd ..</code></li>
<li><code>$ rm -rf cloud-computing-app.git</code></li>
<li><code>$ git clone https://github.com/Omegapoint/<application-name>.git</code></li>
<li><code>$ cd <application-name> b</code></li>
<li>Build the application <code>$ ./gradlew clean build</code></li>
<li>Run the application <code>$ ./gradlew bootRun -Dspring.profiles.active=local</code></li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 1</strong></span> You can now go to <code>http://localhost:8080/cloud-computing-template-app/ping</code> in your browser att receive a <em>"pong"</em>.</p>
<p>If you're using IntelliJ, import the new project by: <em>New Project</em> --> <em>From Existing Sources</em> . Choose Gradle as build tool.</p>
<h3 id="toc_4">Modify applicatin properties</h3>
<p>Change the name of the application in <code>application.properties</code>:</p>
<p>1 .<code>spring.application.name=<application-name></code><br>
2. <code>$ ./gradlew clean build</code> </p>
<p><span style="color:orange"><strong>Checkpoint 2</strong></span> Gradle should now have built the jar <code>build/libs/<application-name>-1.0-SNAPSHOT.jar</code> and you should be able to go to <code>http://localhost:8080/<application-name>/ping</code> in your browser att receive a <em>"pong"</em>.</p>
<p>Create a new property file in <code>src/resources/</code> for production environment: <code>application-production.properties</code> with the following content:</p>
<div><pre class="line-numbers"><code class="language-properties">spring.profiles.active=production
server.port=8080
# Datasource
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
# h2 settings
spring.h2.console.enabled=true
spring.h2.console.path=/h2
</code></pre></div>
<p><span style="color:orange"><strong>Checkpoint 3</strong></span> You can now run the application with:</p>
<p><code>$ java -jar -Dspring.profiles.active=production build/libs/<application-name>-1.0-SNAPSHOT.jar</code> </p>
<p>on your local machine.
<a name="ec2deploy"></a></p>
<h2 id="toc_5">Deploy on EC2</h2>
<h3 id="toc_6">Setup instance</h3>
<p><a href="https://sts.omegapoint.se/adfs/ls/IdpInitiatedSignOn.aspx">Login to AWS</a>. </p>
<ol>
<li><strong>Go to the Service -> EC2 -> Key pairs.</strong> </li>
<li><strong>Create a new key</strong> and download an ssh key. You will use this to connect to instances that you provision during this lab. The key should be called <code><application-name>-key</code> </li>
<li><strong>Choose an Instance Type</strong>
<ul>
<li>Go to the Service -> EC2 -> Instances. </li>
<li>Launch an EC2-instance using Amazon Linux on a <em>t2.micro</em> instance. Click <em>Next: Configure Instance Details</em></li>
</ul></li>
<li><strong>Configure Instance Details</strong> - Leave all fields as default</li>
<li><strong>Add Storage</strong> - Leave all fields as default </li>
<li><strong>Add Tags</strong>
<ul>
<li>Key: <code>Name</code></li>
<li>Value <code><application-name></code></li>
</ul></li>
<li><strong>Configure Security Group 1</strong>
<ul>
<li>Security group name: <code><application-name>-security-group</code></li>
<li>Type: <em>SSH</em></li>
<li>Protocol: <em>TCP</em></li>
<li>Port Range: <code>22</code></li>
<li>Source: <code>My IP</code></li>
<li>Description: <code>SSH for admin</code></li>
</ul></li>
<li><strong>Configure Security Group 2</strong>
<ul>
<li>Type: <em>Custom TCP</em></li>
<li>Protocol: <em>TCP</em></li>
<li>Port Range: <code>8080</code> (or whichever port your application is running)</li>
<li>Source: <code>My IP</code></li>
<li>Description <code><insert-something-smart></code></li>
</ul></li>
<li><strong>Review Instance Launch</strong> - Leave all fields as default</li>
<li><strong>Select an existing key pair or create a new key pair</strong>
<ul>
<li><em>Choose an existing key pair</em></li>
<li><code><application-name>-key</code></li>
</ul></li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 4</strong></span> You can now SSH to your EC2 instance with the key you've generated. The username is <strong>ec2-user</strong>. To ssh with a your key use the following command: <code>ssh -i key.pem ec2-user@[insert public IP of the EC2 instance]</code></p>
<h3 id="toc_7">Manual deploy</h3>
<ol>
<li>Upload your jar to to the instance with scp.</li>
<li>Install java with <code>yes | sudo yum install java-1.8.0</code> and remove Java 1.7 with <code>yes | sudo yum remove java-1.7.0</code></li>
<li>Start the application by using the command <code>java -jar -Dspring.profiles.active=production <application-name>.jar</code>.</li>
<li>Verify that your app is accessible from the internet by browsing the public IP address of the instance.</li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 5</strong></span> You can browse to <code>http://<URL-of-your-ec2>:8080/<application-name>/ping</code> and get the response <em>"pong"</em></p>
<p><a name="database"></a></p>
<h2 id="toc_8">Connect applicatoin to a DB</h2>
<h3 id="toc_9">Local DB</h3>
<p><em>Note: This section ("Local DB") is not mandatory and you could jump directly to "Cloud DB" if you want.</em></p>
<ol>
<li>Install PostgreSQL on your local machine</li>
<li><p>Modify the content of <code>application-local.properties</code>:</p>
<div><pre class="line-numbers"><code class="language-properties">spring.profiles.active=local
server.port=8080
# Datasource
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:postgresql://localhost:5432/<db-name>
spring.datasource.username=<username>
spring.datasource.password=<password></code></pre></div></li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 6</strong></span> You can now go to <code>http://localhost:8080/<application-name>/reverse/omegapoint</code> in your browser att receive the following content:</p>
<div><pre class="line-numbers"><code class="language-javascript">{
"input": <
} </code></pre></div>
<h3 id="toc_10">Cloud DB</h3>
<p><a href="https://sts.omegapoint.se/adfs/ls/IdpInitiatedSignOn.aspx">Login to AWS</a>. Go to <strong>RDS</strong> under <em>"Database"</em>. Click on the orange button <em>"Launch a DB Instance"</em> and choose <em>PostgreSQL</em>. </p>
<p>Make the following choices:</p>
<ol>
<li><p><strong>Choose use case</strong></p>
<ul>
<li>Dev/Test</li>
</ul></li>
<li><p><strong>Specify DB details</strong> </p>
<ul>
<li>DB engine version: <em>PostgreSQL 9.6.2-R1</em></li>
<li>DB instance class: <em>db.t2.micro</em></li>
<li>Allocated storage: <code>20 GB</code></li>
<li>DB instance identifier: <code><application-name>-db-instance</code></li>
<li>Master username: <code><username></code></li>
<li>Master password: <code><password></code></li>
</ul></li>
<li><p><strong>Configure advanced settings</strong></p>
<ul>
<li>Virtual Private Cloud (VPC): <em>Default VPC</em></li>
<li>Public accessibility: <em>Yes</em></li>
<li>Databasename: <code><application-name>-db</code></li>
<li>Databaseport: <code>5432</code></li>
<li>Backup: <em>No preference</em></li>
<li>Monitoring: <em>Disable</em></li>
<li>Maintenance: <em>Disable</em></li>
<li>Maintenance window: <em>No preference</em></li>
</ul>
<p>On your RDS overview, choose <em>"Instances"</em> and collect the following info:</p>
<ul>
<li>Endpoint <code><endpoint></code></li>
<li>DB Name <code><db-name></code></li>
<li>Username <code><username></code></li>
<li>Password <code><password></code></li>
</ul></li>
</ol>
<p>Insert the information into <code>application-production.properties</code> in your project:</p>
<div><pre class="line-numbers"><code class="language-properties">spring.profiles.active=production
server.port=8080
# Datasource
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:postgresql://<endpoint>:5432/<db-name>
spring.datasource.username=<username>
spring.datasource.password=<password></code></pre></div>
<p>Remember to configure the security group of your RDS instance so it allows <em>inbound</em> traffic from your EC2 instance. </p>
<p><span style="color:orange"><strong>Checkpoint 7</strong></span> You should now be able to run <code>java -jar -Dspring.profiles.active=production <application-name>-1.0-SNAPSHOT.jar</code> <strong>on your ec2 instance</strong> and connect your application to the RDS instance. Confirm by going to <code>http://<ec2-url>:8080/<application-name>/reverse/omegapoint</code> in your browser att receive the following content:</p>
<div><pre class="line-numbers"><code class="language-javascript">{
"input": <
} </code></pre></div>
<p><a name="CodePipeline1"></a></p>
<h2 id="toc_11">Code Pipeline preparations</h2>
<p>The goal in this lab is to automatically test and build using CodeBuild and deploy the application after every push to master.
You will deploy using CodeDeploy which requires an agent application to be running on the EC2 instance. Therefore you will provision a new instance (using CloudFormation) and install the agent automatically.</p>
<h3 id="toc_12">Provision new EC2 instance using CloudFormation</h3>
<ol>
<li>Terminate the EC2 instance you provisioned in the previous lab</li>
<li>Download this <a href="http://s3-eu-west-1.amazonaws.com/aws-codedeploy-eu-west-1/templates/latest/CodeDeploy_SampleCF_Template.json">CloudFormation template</a>.</li>
<li>Open the template in an editor. After line 233 we want to install Java 8 and uninstall Java 7 as we did with our previous instance. Add the following lines:</li>
</ol>
<div><pre class="line-numbers"><code class="language-bash">"yum install java-1.8.0 -y \n",
"yum remove java-1.7.0 -y \n",</code></pre></div>
<ol>
<li>Go to the AWS service CloudFormation and click Create stack.</li>
<li>Choose <em>Upload a template to Amazon S3</em> and choose your modified template .json file</li>
<li>Specify details and parameters
<ul>
<li>Stack name: <code><application-name></code></li>
<li>InstanceCount: <code>1</code></li>
<li>InstanceType: <code>t1.micro</code></li>
<li>KeyPairName: <code><application-name>-key</code></li>
<li>OperatingSystem: <code>Linux</code></li>
<li>SSHLocation: <code>My IP</code></li>
<li>TagKey: <code>Name</code></li>
<li>TagValue: <code><application-name></code></li>
</ul></li>
<li> Click Next, then Next again,</li>
<li>Tick the checkbox <em>I acknowledge that AWS CloudFormation might create IAM resources.</em> and click Create.</li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 8</strong></span> Make sure the template creation runs smooth and that your stack in CloudFormation gets the status <em>CREATE_COMPLETE</em>. Find the new EC2 instance and make sure you can SSH to it.</p>
<h3 id="toc_13">Bulid specification for CodeBuild</h3>
<p>CodeBuild requires a buildspec.yml file to be in the root of your application:</p>
<h5 id="toc_14">buildspec.yml</h5>
<div><pre class="line-numbers"><code class="language-yaml">version: 0.2
phases:
build:
commands:
- echo Build started on `date`
- sh gradlew clean assemble
artifacts:
files:
- appspec.yml
- 'build/libs/*.jar'
- start_application.sh
discard-paths: yes</code></pre></div>
<h3 id="toc_15">Deploy specification for CodeDeploy</h3>
<p>CodeDeploy requires two files:</p>
<h5 id="toc_16">appspec.yml</h5>
<div><pre class="line-numbers"><code class="language-yaml">version: 0.0
os: linux
files:
- source: <application-name>-<version>.jar
destination: /tmp
hooks:
ApplicationStart:
- location: start_application.sh
timeout: 500
runas: root</code></pre></div>
<h5 id="toc_17">start_application.sh</h5>
<div><pre class="line-numbers"><code class="language-bash">#!/bin/bash
touch app.log
nohup java -jar /tmp/*.jar -Dspring.profiles.active=production > app.log 2>&1 &</code></pre></div>
<p>You may have to modify these files to fit your application.</p>
<p><span style="color:orange"><strong>Checkpoint 9</strong></span> Push these files to your repository.
<a name="CodePipeline2"></a></p>
<h2 id="toc_18">Create the CodePipeline</h2>
<ol>
<li>Go to the service CodePipeline and click <em>Create Pipeline</em></li>
<li>Name it <code><application-name>-CodePipeline</code> and click next step</li>
<li>For <em>Source provider</em> chooce Github and click <em>Connect to Github</em> and authorize AWS to access your Github resources</li>
<li>In <em>Repository</em> choose your application repository, then select the branch on which the version of the application that you want to deploy is (typiclly <em>master</em>). Then click <em>next</em>.</li>
</ol>
<h4 id="toc_19">CodeBuild</h4>
<ul>
<li><strong>Build</strong>
<ul>
<li>Build provider: <code>AWS CodeBuild</code></li>
<li>Configure your project -> Create a new build project</li>
<li>Project Name: <code><application-name>-CodeBuild</code></li>
</ul></li>
<li><strong>Environment: How to build</strong>
<ul>
<li>Environment image: <code>Use an image managed by AWS CodeBuild</code></li>
<li>Operating system: <code>Ubuntu</code></li>
<li>Runtime: <code>Java</code></li>
<li>Version: <em>"aws/codebuild/java:openjdk-8"</em></li>
<li>Build specification: <em>"Use the buildspec.yml in the source code root directory"</em></li>
</ul></li>
<li><strong>AWS CodeBuild service role</strong>
<ul>
<li>Select <em>Create a service role in your account</em></li>
<li>Role name: Leave as default</li>
<li>Click <em>Save build project</em></li>
<li>After the build project is saved click <em>Next step</em></li>
</ul></li>
</ul>
<h4 id="toc_20">CodeDeploy</h4>
<p>Deployment provider: <code>AWS CodeDeploy</code></p>
<ul>
<li><strong>AWS CodeDeploy</strong>
<ul>
<li>Click the link <em>create a new one in AWS CodeDeploy</em></li>
<li>Application name: <code><application-name>-Application</code></li>
<li>Deployment group: <code><application-name>-DeploymentGroup</code></li>
<li>Deployment type: In-place deployment</li>
</ul></li>
<li><strong>Environment configuration</strong>
<ul>
<li>Choose Amazon EC2 instances</li>
<li>Key: <code>Name</code></li>
<li>Value: <code><application-name></code> make sure you see the EC2 instance created by the CloudFormation template in the <em>Matching instances</em> section</li>
<li>Do not tick the box <em>Enable load balancing</em></li>
</ul></li>
<li><strong>Deployment configuration</strong>
<ul>
<li>Leave as default</li>
</ul></li>
<li><strong>Service role</strong>
<ul>
<li>Service role ARN: Select the role named <code>BlueGreenCodeDeployServiceRole</code></li>
<li>Click create application</li>
</ul></li>
</ul>
<h4 id="toc_21">CodePipeline</h4>
<p>Go back to the pipeline tab</p>
<ul>
<li><strong>AWS CodeDeploy</strong>
<ul>
<li>Application name: <code><application-name>-Application</code></li>
<li>Deployment group: <code><application-name>-DeploymentGroup</code></li>
<li>Click <em>Next step</em></li>
<li>Role name: <code>AWS-CodePipeline-Service</code></li>
<li>Click <em>Next step</em></li>
<li>Review your pipeline, then click <em>Create pipeline</em></li>
</ul></li>
</ul>
<p><span style="color:orange"><strong>Checkpoint 10</strong></span> At this point you should see your pipeline. Unless it starts automatically click <code>Release change</code>. Make sure your source code is built and deployed successfully. If there are issues, resolve these before moving on.</p>
<p><a name="Balancer"></a></p>
<h2 id="toc_22">Load balancing with Elastic Load Balancer</h2>
<ol>
<li>Go to EC2 -> Load Balancers and click <em>Create Load Balancer</em></li>
<li><em>Create</em> an Application Load Balancer</li>
<li><strong>Basic Configuration</strong>
<ul>
<li>Name: <code><application-name>-ALB</code></li>
<li>Scheme: <em>internet-facing</em></li>
<li>IP address type: <em>ipv4</em></li>
</ul></li>
<li><strong>Listeners</strong>
<ul>
<li>Leave as default</li>
</ul></li>
<li><strong>Availability Zones</strong>
<ul>
<li>VPC: Select whichever VPC is marked <em>default</em></li>
<li>Select all availability zones</li>
<li>Click _Next: Configure Security Settings</li>
</ul></li>
<li><strong>Conigure Security Settings</strong>
<ul>
<li>Leave as defualt, click <em>Next: Configure Security Groups</em></li>
</ul></li>
<li><strong>Configure Security Groups</strong>
<ul>
<li>Choose <em>Select an <strong>existing</strong> seurity group</em></li>
<li>Select the group previously created: <code><application-name>-security-group</code></li>
<li>Click <em>Next: Configure Routing</em></li>
</ul></li>
<li><strong>Configure Routing</strong>
<ul>
<li>Target group: New target group</li>
<li>Name: <code><application-name>-TargetGroup</code></li>
<li>Protocol: HTTP</li>
<li>Port: 8080 (or the custom port on which your application is running)</li>
<li>Target type: instance</li>
<li><strong>Healtch Checks</strong></li>
<li>Protocol: HTTP</li>
<li>Path: any valid path where your application responds with <code>HTTP 200</code></li>
<li><strong>Advanced healthcheck settings</strong></li>
<li>Port: traffic port</li>
<li>Healthy treshold: 2</li>
<li>Unhealthy treshold: 2</li>
<li>Timeout: 5</li>
<li>Interval: 10</li>
<li>Success codes: 200-299</li>
<li>Click <em>Next: Register Targets</em></li>
</ul></li>
<li><strong>Register Targets</strong>
<ul>
<li>Search for your EC2 instance in the <em>Instances</em> section</li>
<li>Select your instance and click <em>Add to registered</em></li>
<li>Click <em>Next: Review</em></li>
</ul></li>
<li><strong>Review</strong>
<ul>
<li>Review your Load Balancer configuration and click <em>Create</em></li>
</ul></li>
</ol>
<p><span style="color:orange"><strong>Checkpoint 10</strong></span> Verify your ALB is working</p>