1
00:00:02,060 --> 00:00:04,100
So let's now work on getting

2
00:00:04,100 --> 00:00:06,780
that database hosting up and running.

3
00:00:06,780 --> 00:00:09,810
For this I searched for Mongo DB Atlas,

4
00:00:09,810 --> 00:00:12,579
since this will be the managed service we'll be using for

5
00:00:12,579 --> 00:00:14,610
the reasons mentioned before.

6
00:00:14,610 --> 00:00:18,300
And the great thing about Mongo DB Atlas is that you can get

7
00:00:18,300 --> 00:00:20,560
started for free.

8
00:00:20,560 --> 00:00:23,544
Here if you go to the pricing page to the cloud offering,

9
00:00:23,544 --> 00:00:28,370
you can get started for free with this shared plan here.

10
00:00:28,370 --> 00:00:31,448
And hence, we can simply click on, try for free here.

11
00:00:31,448 --> 00:00:36,140
Though, as always, if you are serious about your website

12
00:00:36,140 --> 00:00:39,220
and also your database therefore, the free plan,

13
00:00:39,220 --> 00:00:41,140
of course has certain restrictions

14
00:00:41,140 --> 00:00:44,050
you might not be too happy with in the long term.

15
00:00:44,050 --> 00:00:46,960
And therefore you might want to consider upgrading to one of

16
00:00:46,960 --> 00:00:48,173
the paid options,

17
00:00:48,173 --> 00:00:51,930
if you have more traffic and more requests.

18
00:00:51,930 --> 00:00:54,710
But to get started, the free plan is great.

19
00:00:54,710 --> 00:00:57,379
You don't even need a credit card as you see here.

20
00:00:57,379 --> 00:00:58,670
And therefore now

21
00:00:58,670 --> 00:01:02,690
we can enter our email address to create a new account here.

22
00:01:02,690 --> 00:01:05,540
Now, here I'll quickly fill in my details

23
00:01:08,330 --> 00:01:10,710
and then click create account.

24
00:01:10,710 --> 00:01:14,210
And this will now create us such a free Mongo DB Atlas

25
00:01:14,210 --> 00:01:15,220
account.

26
00:01:15,220 --> 00:01:17,530
And once that finished as a next step,

27
00:01:17,530 --> 00:01:20,850
you'll have to verify your account.

28
00:01:20,850 --> 00:01:23,863
So that's the next thing you should do.

29
00:01:24,800 --> 00:01:26,529
And there after, you can sign in

30
00:01:26,529 --> 00:01:28,723
with that account you created.

31
00:01:29,800 --> 00:01:31,800
Now, initially you should end up

32
00:01:31,800 --> 00:01:34,950
on a starting screen that looks something like this.

33
00:01:34,950 --> 00:01:38,203
And here you can now click on, build a database.

34
00:01:39,350 --> 00:01:41,846
Now, here, we want to go with that, right

35
00:01:41,846 --> 00:01:45,110
most option, the basic option,

36
00:01:45,110 --> 00:01:47,083
because that's available for free.

37
00:01:48,750 --> 00:01:51,130
And then here's stick to basic.

38
00:01:51,130 --> 00:01:54,420
Now we can choose the underlying cloud provider,

39
00:01:54,420 --> 00:01:57,310
which will be used by Mongo DB Atlas.

40
00:01:57,310 --> 00:01:59,760
And we can stick to AWS for this.

41
00:01:59,760 --> 00:02:03,510
As a side note, you could also directly use AWS.

42
00:02:03,510 --> 00:02:08,509
They offer tons of services related to hosting and other

43
00:02:09,610 --> 00:02:12,220
services that run on remote machines.

44
00:02:12,220 --> 00:02:14,350
But here we'll use Mongo DB Atlas,

45
00:02:14,350 --> 00:02:17,090
which uses AWS implicitly.

46
00:02:17,090 --> 00:02:20,670
And I'll keep all these default settings here.

47
00:02:20,670 --> 00:02:24,343
Under a cluster here we want to use the free forever option,

48
00:02:25,380 --> 00:02:28,376
the M0 sandbox, which should be the default.

49
00:02:28,376 --> 00:02:30,081
We use that database version.

50
00:02:30,081 --> 00:02:33,860
We can keep the default cluster name or give it a different

51
00:02:33,860 --> 00:02:34,950
name.

52
00:02:34,950 --> 00:02:37,580
As a side note, a cluster is in the end

53
00:02:37,580 --> 00:02:41,140
the thing that will run your databases later.

54
00:02:41,140 --> 00:02:44,320
And therefore, then we can click on create cluster

55
00:02:44,320 --> 00:02:48,060
so that this cluster with the databases is created.

56
00:02:48,060 --> 00:02:49,610
And as it says here,

57
00:02:49,610 --> 00:02:52,483
this can take a couple of minutes until it's done.

58
00:02:53,520 --> 00:02:56,260
Now, we don't have to sit here and wait for it though.

59
00:02:56,260 --> 00:02:59,240
We can already go to the security area because there,

60
00:02:59,240 --> 00:03:01,533
we got two things that we need to tweak.

61
00:03:02,562 --> 00:03:05,410
First with the database access.

62
00:03:05,410 --> 00:03:09,140
Here we want to add a new database user

63
00:03:09,140 --> 00:03:10,540
because that will be the user

64
00:03:10,540 --> 00:03:13,470
with whom we then connect to this database.

65
00:03:13,470 --> 00:03:14,490
So this controls,

66
00:03:14,490 --> 00:03:17,751
the permissions are node JS application will have when it

67
00:03:17,751 --> 00:03:21,253
connects to this database, through this user.

68
00:03:22,620 --> 00:03:25,240
And for this I'll choose password as the authentication

69
00:03:25,240 --> 00:03:27,490
method, and then add a new user.

70
00:03:27,490 --> 00:03:31,023
Which all named Maximilian or default or whatever you want.

71
00:03:31,940 --> 00:03:36,650
And add a password and I'll choose a fairly insecure one

72
00:03:36,650 --> 00:03:37,483
here.

73
00:03:37,483 --> 00:03:40,980
You of course should probably auto-generate one and then

74
00:03:40,980 --> 00:03:44,823
copy that. But here I'll use my own one for this demo.

75
00:03:46,410 --> 00:03:50,010
And then here very important for the database user

76
00:03:50,010 --> 00:03:50,890
privilege.

77
00:03:50,890 --> 00:03:54,550
We want to choose read and write to any database.

78
00:03:54,550 --> 00:03:56,823
That is what our users should be able to do.

79
00:03:58,270 --> 00:04:00,213
Then we can click add user here.

80
00:04:01,050 --> 00:04:03,633
And next we can move on to network access.

81
00:04:04,620 --> 00:04:07,300
Here on the network access page,

82
00:04:07,300 --> 00:04:11,840
we can control which other servers and machines will be

83
00:04:11,840 --> 00:04:14,580
able to connect to our database.

84
00:04:14,580 --> 00:04:17,300
And here under IP access list,

85
00:04:17,300 --> 00:04:20,120
we want to click on add IP address.

86
00:04:20,120 --> 00:04:23,250
And now we could add our current IP address,

87
00:04:23,250 --> 00:04:26,770
if we would want to use Mongo DB Atlas from our local

88
00:04:26,770 --> 00:04:27,620
machine.

89
00:04:27,620 --> 00:04:30,870
If we would run the node express website on our local

90
00:04:30,870 --> 00:04:33,795
machine and that locally running websites should connect to

91
00:04:33,795 --> 00:04:36,280
Mongo DB Atlas.

92
00:04:36,280 --> 00:04:39,100
But of course that won't do the trick if our website

93
00:04:39,100 --> 00:04:41,730
is running on Heroku's machines,

94
00:04:41,730 --> 00:04:44,793
Because dos machines will have different IP addresses.

95
00:04:45,720 --> 00:04:46,920
Therefore for that,

96
00:04:46,920 --> 00:04:49,356
we could either enter the IP address off the server

97
00:04:49,356 --> 00:04:51,910
our website will run on.

98
00:04:51,910 --> 00:04:54,552
If we knew that IP address in advance,

99
00:04:54,552 --> 00:04:58,500
but with the basic Heroku deployment option,

100
00:04:58,500 --> 00:05:02,290
we don't know that in advance because Heroku will assign IP

101
00:05:02,290 --> 00:05:04,340
addresses dynamically.

102
00:05:04,340 --> 00:05:06,500
And therefore I'll choose allow access from

103
00:05:06,500 --> 00:05:09,090
anywhere, which means everyone will be able

104
00:05:09,090 --> 00:05:10,648
to connect to our database.

105
00:05:10,648 --> 00:05:13,980
Though that sounds a bit more insecure than it is

106
00:05:13,980 --> 00:05:17,080
because you will also need the user credentials,

107
00:05:17,080 --> 00:05:19,620
which we set up a couple of minutes ago.

108
00:05:19,620 --> 00:05:22,540
So just with that access granted alone,

109
00:05:22,540 --> 00:05:25,950
it's not the case that everyone will be able to connect.

110
00:05:25,950 --> 00:05:28,660
The user credentials also the matter.

111
00:05:28,660 --> 00:05:31,480
So here I'll set up this.

112
00:05:31,480 --> 00:05:36,080
Everyone is allowed to send connection requests setting.

113
00:05:36,080 --> 00:05:38,060
And with that, we can now wait

114
00:05:38,060 --> 00:05:41,020
until our database is done starting up.

115
00:05:41,020 --> 00:05:44,700
So once this cluster is done and once this network access is

116
00:05:44,700 --> 00:05:46,030
done, configuring,

117
00:05:46,030 --> 00:05:48,590
and then we'll be able to continue with deploying our

118
00:05:48,590 --> 00:05:50,110
website.

119
00:05:50,110 --> 00:05:53,259
So here that cluster did now start successfully.

120
00:05:53,259 --> 00:05:57,500
And now we can click on connect here to learn how we can

121
00:05:57,500 --> 00:05:58,880
connect to it.

122
00:05:58,880 --> 00:06:00,450
Now there are various options,

123
00:06:00,450 --> 00:06:02,800
but we want to connect our application.

124
00:06:02,800 --> 00:06:05,290
So our website, so we can click on this.

125
00:06:05,290 --> 00:06:08,080
And indeed we are using Node.js.

126
00:06:08,080 --> 00:06:10,280
So we can leave that default.

127
00:06:10,280 --> 00:06:13,070
And the latest version of that Mongo DB driver,

128
00:06:13,070 --> 00:06:16,280
which is that Mongo D package, which we're using.

129
00:06:16,280 --> 00:06:18,300
And they after then here we get the URL,

130
00:06:18,300 --> 00:06:22,510
which we can use to connect to our database.

131
00:06:22,510 --> 00:06:26,470
It has this user, which I created automatically filled in.

132
00:06:26,470 --> 00:06:28,303
So that will be part of that URL.

133
00:06:29,590 --> 00:06:32,040
And we have this password placeholder,

134
00:06:32,040 --> 00:06:34,780
which we will have to populate with the user password

135
00:06:34,780 --> 00:06:35,673
ourselves.

136
00:06:36,930 --> 00:06:38,310
Now that's the URL,

137
00:06:38,310 --> 00:06:41,110
which we would now want to use instead of this URL,

138
00:06:41,110 --> 00:06:42,296
but keep in mind,

139
00:06:42,296 --> 00:06:45,050
we're using environment variables for this.

140
00:06:45,050 --> 00:06:49,420
So I will keep this URL here for local development

141
00:06:49,420 --> 00:06:52,390
and we'll provide the production URL.

142
00:06:52,390 --> 00:06:57,350
So this URL here, through an environment variable after we

143
00:06:57,350 --> 00:07:00,670
deployed our website to Heroku.

144
00:07:00,670 --> 00:07:03,570
And therefore I'll keep this window open here,

145
00:07:03,570 --> 00:07:06,307
but I'll continue with the deployment steps now.

146
00:07:06,307 --> 00:07:09,367
Since now we can continue with pushing our code

147
00:07:09,367 --> 00:07:13,073
to Heroku and starting our website there.

