1
00:00:00,160 --> 00:00:03,230
Okay. So let's practice creating an application balancer

2
00:00:03,230 --> 00:00:06,030
of type HTTP and HTTPS.

3
00:00:06,030 --> 00:00:08,840
So let's create it, and we can have a look

4
00:00:08,840 --> 00:00:10,320
at how application balances work.

5
00:00:10,320 --> 00:00:12,500
We have a really nice graph around it,

6
00:00:12,500 --> 00:00:14,010
but we know this already.

7
00:00:14,010 --> 00:00:15,158
So what is the name going to be?

8
00:00:15,158 --> 00:00:17,100
Well, it's going to be DemoALB

9
00:00:17,100 --> 00:00:19,450
and we can either have an internet-facing ALB

10
00:00:19,450 --> 00:00:22,360
or an internal facing ALB, but this is for private traffic.

11
00:00:22,360 --> 00:00:24,980
So, because we want to publicly access our application,

12
00:00:24,980 --> 00:00:27,840
currently, we're going to use an internet facing scheme.

13
00:00:27,840 --> 00:00:30,700
Then we're going to use an IPv4 type of stack

14
00:00:30,700 --> 00:00:34,460
for getting access to our load balancer.

15
00:00:34,460 --> 00:00:35,340
Okay.

16
00:00:35,340 --> 00:00:37,990
Next, in terms of network mapping, we have to specify a VPC

17
00:00:37,990 --> 00:00:40,277
we're going to operate in, as well as how many subnets

18
00:00:40,277 --> 00:00:41,910
and AZs we want to operate in.

19
00:00:41,910 --> 00:00:44,690
So I'm going to take all three subnets,

20
00:00:44,690 --> 00:00:47,370
so, eu-west 1b, 1c, and 1a

21
00:00:47,370 --> 00:00:49,280
and they will automatically get the right sub-net

22
00:00:49,280 --> 00:00:50,440
assigned to them.

23
00:00:50,440 --> 00:00:51,300
Perfect.

24
00:00:51,300 --> 00:00:53,550
Next, we need to assign a security group

25
00:00:53,550 --> 00:00:56,120
to our load balancer. So we already have created one.

26
00:00:56,120 --> 00:00:58,180
So my first load balancer security group

27
00:00:58,180 --> 00:00:59,900
is going to be assigned to it.

28
00:00:59,900 --> 00:01:03,830
And then we need to specify listeners and routing.

29
00:01:03,830 --> 00:01:04,920
So this is saying, hey,

30
00:01:04,920 --> 00:01:07,510
if someone is accessing our load balancer on,

31
00:01:07,510 --> 00:01:12,170
from the protocol HTTP on port 80, then forward to,

32
00:01:12,170 --> 00:01:15,240
and we need to create a target group for this.

33
00:01:15,240 --> 00:01:18,260
So we go ahead and create a new target group.

34
00:01:18,260 --> 00:01:20,580
And that's going to be based on instances

35
00:01:20,580 --> 00:01:21,940
so you have different target groups possible

36
00:01:21,940 --> 00:01:24,990
for our ALB. Could be instances, IP addresses,

37
00:01:24,990 --> 00:01:26,827
Lambda function or an ALB,

38
00:01:26,827 --> 00:01:28,370
but this is only when we're using an ALB.

39
00:01:28,370 --> 00:01:30,980
So the one we want to use right now is instances.

40
00:01:30,980 --> 00:01:32,120
So this is, we want to have

41
00:01:32,120 --> 00:01:35,880
the ALB sent data into our network traffic,

42
00:01:35,880 --> 00:01:37,610
into our EC2 instances.

43
00:01:37,610 --> 00:01:39,557
So the target group name is going to be

44
00:01:39,557 --> 00:01:42,857
"my-first-target-group".

45
00:01:43,940 --> 00:01:46,530
And the protocol is, HTTP port 80.

46
00:01:46,530 --> 00:01:49,920
The VPC is this one. HTTP1 is fine.

47
00:01:49,920 --> 00:01:51,970
And then we're going to scroll down,

48
00:01:51,970 --> 00:01:53,150
health checks so we can specify

49
00:01:53,150 --> 00:01:55,100
some advanced health check settings for it too.

50
00:01:55,100 --> 00:01:58,130
So number of health is going to be three.

51
00:01:58,130 --> 00:01:59,320
Unhealthy is going to be two,

52
00:01:59,320 --> 00:02:01,310
timeouts going to be four seconds

53
00:02:01,310 --> 00:02:03,640
and interval is going to be five seconds.

54
00:02:03,640 --> 00:02:07,120
Okay. So this is good. And the success code is 200.

55
00:02:07,120 --> 00:02:09,110
So we'll click on next,

56
00:02:09,110 --> 00:02:10,710
and then we're going to register two

57
00:02:10,710 --> 00:02:12,970
out of the three instances we have.

58
00:02:12,970 --> 00:02:14,310
So make sure to only include two

59
00:02:14,310 --> 00:02:15,980
and I'll show you why after. Okay.

60
00:02:15,980 --> 00:02:17,440
So review targets,

61
00:02:17,440 --> 00:02:20,480
We have two targets out of the three available instances.

62
00:02:20,480 --> 00:02:22,250
So now let's create this target group.

63
00:02:22,250 --> 00:02:24,830
So it has been created, now back into our load balancer.

64
00:02:24,830 --> 00:02:27,630
We can refresh this and select my first target group.

65
00:02:27,630 --> 00:02:28,750
Very nice.

66
00:02:28,750 --> 00:02:31,510
So here's a summary. We have a DemoALB,

67
00:02:31,510 --> 00:02:33,330
internet-facing on IPV4.

68
00:02:33,330 --> 00:02:35,550
Attached to it is one security group.

69
00:02:35,550 --> 00:02:38,150
Network mapping is, has three AZs

70
00:02:38,150 --> 00:02:41,880
and port 80 HTTP redirects to my first target group.

71
00:02:41,880 --> 00:02:44,760
Okay. Let's create this load balancer and now we're done.

72
00:02:44,760 --> 00:02:46,250
So let's view the load balancers

73
00:02:46,250 --> 00:02:49,180
and now we have to wait for it to be provisioned.

74
00:02:49,180 --> 00:02:52,170
Okay, so my ALB is now provisioned

75
00:02:52,170 --> 00:02:54,730
and I can go to my DNS name, open it.

76
00:02:54,730 --> 00:02:57,460
And then I get the hello world from the IP.

77
00:02:57,460 --> 00:03:00,440
And if I refresh again, I get the different Hello World

78
00:03:00,440 --> 00:03:01,730
from a different EC2 instances.

79
00:03:01,730 --> 00:03:05,400
So my ALB is working as expected,

80
00:03:05,400 --> 00:03:06,380
just like the CLB did,

81
00:03:06,380 --> 00:03:08,500
but because this is an application balancer,

82
00:03:08,500 --> 00:03:10,610
we get some added benefits.

83
00:03:10,610 --> 00:03:11,830
And so to prove this to you,

84
00:03:11,830 --> 00:03:13,710
I'm going to go into target groups

85
00:03:13,710 --> 00:03:16,090
and I'm going to create a second target group.

86
00:03:16,090 --> 00:03:17,447
So we have my first target group,

87
00:03:17,447 --> 00:03:20,650
I'm going to create a target group based on instances,

88
00:03:20,650 --> 00:03:24,177
and I'll call it "my-second-target-group".

89
00:03:25,450 --> 00:03:28,410
And then we have this VPC, which is perfect,

90
00:03:28,410 --> 00:03:30,010
We have HTTP1,

91
00:03:30,010 --> 00:03:33,090
scroll down the health check just looks like before,

92
00:03:33,090 --> 00:03:35,837
so healthy threshold three, unhealthy,

93
00:03:35,837 --> 00:03:39,130
timeout four, interval five.

94
00:03:39,130 --> 00:03:43,230
Here we go and click on next. And then I can register,

95
00:03:43,230 --> 00:03:46,050
I can't remember which one it is, but one missing instance.

96
00:03:46,050 --> 00:03:47,220
The one that is not,

97
00:03:47,220 --> 00:03:48,750
it doesn't really matter which one you choose.

98
00:03:48,750 --> 00:03:50,100
But anyway, I will just add one instance

99
00:03:50,100 --> 00:03:52,510
for the sake of this purpose, once I decide,

100
00:03:52,510 --> 00:03:54,660
and I will include as pending below,

101
00:03:54,660 --> 00:03:56,870
which is a target for my target group,

102
00:03:56,870 --> 00:03:58,540
create this target group.

103
00:03:58,540 --> 00:04:00,710
And now we have a second target group.

104
00:04:00,710 --> 00:04:03,740
So the cool thing is that if we go back into our ALB,

105
00:04:03,740 --> 00:04:06,750
now we can have multiple listeners

106
00:04:06,750 --> 00:04:08,330
redirect to multiple target groups.

107
00:04:08,330 --> 00:04:10,950
So right now we have one listener port 80

108
00:04:10,950 --> 00:04:12,587
that is forwarding to my first target group.

109
00:04:12,587 --> 00:04:16,450
But we can view and edit the rules of this listener

110
00:04:16,450 --> 00:04:18,660
to start leveraging other target groups.

111
00:04:18,660 --> 00:04:21,800
So I can add a rule in here and I can say, okay,

112
00:04:21,800 --> 00:04:25,260
if the path is, for example, slash tests,

113
00:04:25,260 --> 00:04:27,870
then you should forward your response

114
00:04:27,870 --> 00:04:30,500
to my second target group.

115
00:04:30,500 --> 00:04:34,160
And the idea behind this is that, okay, now if we save this,

116
00:04:34,160 --> 00:04:36,180
well, we have two rules and the first one

117
00:04:36,180 --> 00:04:38,050
that's going to be evaluated is the path.

118
00:04:38,050 --> 00:04:39,970
And it goes to my second target group if it matches,

119
00:04:39,970 --> 00:04:43,890
else by default, you should route to my first target group.

120
00:04:43,890 --> 00:04:44,790
And we can insert manuals.

121
00:04:44,790 --> 00:04:49,130
For example, we can say, if the path is slash constant,

122
00:04:49,130 --> 00:04:51,160
then return a fixed response,

123
00:04:51,160 --> 00:04:56,160
which Is maybe 4 0 4, constant error response,

124
00:04:56,510 --> 00:04:57,810
whatever you want to think of.

125
00:04:57,810 --> 00:04:59,950
And again, save this.

126
00:04:59,950 --> 00:05:01,650
And now we have different rules for our load balancer,

127
00:05:01,650 --> 00:05:02,800
so you can create it,

128
00:05:02,800 --> 00:05:04,995
but you can see how we are way more powerful

129
00:05:04,995 --> 00:05:06,950
than the classic load balancer.

130
00:05:06,950 --> 00:05:10,070
And we can do routing based on path, host header,

131
00:05:10,070 --> 00:05:12,870
HTTP header, query string, source IP and so on.

132
00:05:12,870 --> 00:05:16,090
So you can get very creative with this load balancer.

133
00:05:16,090 --> 00:05:17,960
So let's, let's try it out, let's check it out.

134
00:05:17,960 --> 00:05:21,350
So we go to the DemoALB, we take the DNS,

135
00:05:21,350 --> 00:05:23,070
which is right here, which is already open in here.

136
00:05:23,070 --> 00:05:26,290
So, this works, for now we are only gonna get two instances.

137
00:05:26,290 --> 00:05:28,770
If I do slash constant,

138
00:05:28,770 --> 00:05:30,430
I'm going to get the constant error response

139
00:05:30,430 --> 00:05:33,180
directly sent by my load balancer,

140
00:05:33,180 --> 00:05:35,890
and if I go to slash test, well, it's not going to work.

141
00:05:35,890 --> 00:05:38,190
I'm going to get a not found because my EC2 instance

142
00:05:38,190 --> 00:05:42,440
is not configured to reply to the slash test type of query.

143
00:05:42,440 --> 00:05:44,350
But this query is actually being redirected

144
00:05:44,350 --> 00:05:46,772
to my secondary group, which sort of proves the point

145
00:05:46,772 --> 00:05:48,253
I was trying to make.

146
00:05:49,650 --> 00:05:51,780
So to finish this, let's go and clean it up.

147
00:05:51,780 --> 00:05:52,613
So in the listeners,

148
00:05:52,613 --> 00:05:55,170
I can just remove some rules that I've created.

149
00:05:55,170 --> 00:05:57,720
So these two will be removed.

150
00:05:57,720 --> 00:06:02,530
I will delete them, then back into my target groups.

151
00:06:02,530 --> 00:06:04,793
I will delete my second target group.

152
00:06:06,350 --> 00:06:07,900
And in my first target group,

153
00:06:07,900 --> 00:06:09,733
I'm going to just register one more target.

154
00:06:09,733 --> 00:06:13,290
So I will register targets and make sure that,

155
00:06:13,290 --> 00:06:15,230
I can't remember which ones, so I'll add them three

156
00:06:15,230 --> 00:06:16,450
and then, okay.

157
00:06:16,450 --> 00:06:19,140
One, Okay. This one is being added. So that's perfect.

158
00:06:19,140 --> 00:06:21,130
Click on register pending targets.

159
00:06:21,130 --> 00:06:22,430
And here we go.

160
00:06:22,430 --> 00:06:24,460
So as you can see, this is the target group now,

161
00:06:24,460 --> 00:06:25,950
which will perform the health checks

162
00:06:25,950 --> 00:06:27,750
and make sure that all the instances are healthy.

163
00:06:27,750 --> 00:06:30,510
So now three instances that are healthy out of three.

164
00:06:30,510 --> 00:06:31,540
So this is perfect.

165
00:06:31,540 --> 00:06:35,020
So that means that if we go back into our load balancer,

166
00:06:35,020 --> 00:06:38,520
at the root of the URL, we get hello world from one,

167
00:06:38,520 --> 00:06:42,010
two, and three kind of instances. So that's perfect.

168
00:06:42,010 --> 00:06:43,910
Our target group is working properly.

169
00:06:43,910 --> 00:06:46,930
So is our ALB and that's it.

170
00:06:46,930 --> 00:06:48,360
So I hope you liked this lecture

171
00:06:48,360 --> 00:06:50,310
and I will see you in the next lecture.

