and welcome back to Backspace Academy in this lecture on an elastic file system 2
we'll explore EFS as an option for Amazon ec2 or as a storage option for Amazon ec2 3
will create an EFS share and EFS mount points in multiple availability zones 4
and will then create an ec2 instance and mount the EFS share using the linux 5
operating system of that ec2 instance through an EFS mount point so we're 6
going to create and if it's share in the US east one region and we're going to 7
use the default VPC simply because it's already got subnets created within all 8
the availability zones it's going to make life a little bit easier for us so 9
we can see there we've got our multiple availability zones for that US East a 10
wine region and what we're going to do is we're going to create mount targets 11
for each one of those subnets and you cannot create a mount target unless 12
there is a subnet inside the availability zone and then we're going 13
to use one of those availability zones one of those subjects within that 14
availability zone to launch an ec2 instance into and we're going to connect 15
into that instance and mount to that EFS mount target to that ec2 instance using 16
the Linux operating system 17
okay so I'm just here in the EFS console if you haven't created an elastic 18
filesystem before you'll be presented with this Welcome screen so we're just 19
going to click on create filesystem and we select the VPC that we're going to 20
be putting out mount points into so I've only got the default VPC on on this 21
account so we'll leave it at that now what it will do is it will create 22
mount targets for us now mount targets need to be located in a VPC subnet if 23
you don't have any subnets in the availabilities 24
oan then you won't be able to create a mount target for that availability zone 25
so here because I'm using the default VPC which has subnets in each 26
availability zone we have an option there too that we can select to create a 27
mount point in that availability zone but if we didn't have for example it 28
here if we didn't have a subnet in us east one D that option to create a mount 29
point in u.s. East one D it would not be available for us then we have our 30
security groups that will be associated with this mount target so I'm just going 31
to leave it for now with the default security or the default VPC security 32
groups that have been Auto populated there for me but we will change that 33
later on to add our security group that is associated with our ec2 instance that 34
we're going to create later so I'll just click on the next step and we just give 35
this a name that will do and we're just going to use general purpose default 36
setting for performance mode and next step so now we've just got to review it 37
and create our file system so we can see there we've got our default VPC that 38
it's going to be associated with and we have our mount points here for each one 39
of the availability zones of that default VPC and the security group will 40
be the default VPC security group that the that the mount points will be 41
associated with and we've got our name tag there of course some creep shot 42
create file system 43
so after a certain amount of time we're going to get this up and what it will be 44
doing is it will have its lifecycle state as being creating so we need to 45
allow a few minutes for that to go to from creating to available and then we 46
can go on and create a ec2 instance and start mounting this using that mount 47
point so after a few minutes we'll see that the lifecycle state will change to 48
available you just need to click on refresh up here and refresh it if it 49
doesn't come up after a certain amount of time and so that is our elastic file 50
system setup our EFS share has been set up so what we need to do now is 51
to go into the ec2 service and create a ec2 instance and launch it in one of 52
these availability zones 53
so we're launchin instance we're just going to use the Amazon Linux AMI 54
We will just use a t2 micro and we'll make sure that we have a public IP address 55
and we don't need to add storage add tags it's going to add a name tag for 56
this and we're going to call it the EFS test that'll do 57
ok so now we need to create a security group so I'm just going to give this a 58
name EFS test or EFS security group maybe 59
that will do your security group so two things that we need for this security 60
group is we need to have to be able to connect into it to have SSH into it and 61
on port 22 which we've got there we also need to later on after we've created 62
this to add a rule that will allow NFS inbound for our EFS share so we're not 63
going to do that now we'll do that after I've created the ec2 instance so we just 64
click on review and launch, and launch, we will use a key pair that we've used 65
before 66
so there's our instance all happening so what I'm going to do is go into this 67
efs security group we created before and I'm going to copy its ID and 68
I'm going to jump back into the EFS console and I'm going to modify our file 69
system access so I'm going to modify all these mapping this mount target and we 70
need to have access for that for our security group so you're only to click 71
on here many file system access so I can go up to here and manage file system 72
access and what I'm going to do is add two US East one a the security group for 73
our ec2 instance which is here EFS - SG so it's always good practice to make 74
sure that you put that security group in all of your availability zones which is 75
what I'm just going to do now so just going to select that in there for each 76
availability zone and save that 77
and there we can see all of the availability zones are set up to use 78
that EFS security group or are associated with EFS security group so 79
the next thing we need to do is to allow inbound access to our ec2 instance from 80
our EFS share otherwise we're not going to be able to mount that so we go into 81
security group here upwards through select our ec2 instance we go to the 82
security group for that and click on it and then we can add an inbound rule for 83
that so just add another inbound rule, so add, which will be a NFS and that will be 84
custom with our security group so it'll be SG and that security group that we 85
used before and if we save that that will be all we need to do from a 86
security perspective to allow us to mount the EFS share on our ec2 instance 87
so we've associated the ec2 security group without rio fester and we've also 88
done the same for the ec2 instance as well to associate the EFS share to that 89
as well so what we need to do now is to connect into this ec2 instance and mount 90
our EFS mount target 91
so before we start connecting into our instance just want to jump back into the 92
EFS console again and if we look at our file system here we can see that we have 93
mount instructions for ec2 so just click on that and what that does is it saves 94
us a fair bit of time here so we just don't need to worry about this setting 95
up your ec2 instance we've already done that now there is an instruction here to 96
do a sudo yum install of the NFS client so because we're using the amazon linux 97
ami we don't need to worry about that it already comes pre-installed with the NFS 98
client on it so ignore that so all this first setting up ec2 instance has 99
already been done so the only thing we need to do now is 100
to mount our file system so we need to make a directory for our for our mount 101
point so we create or make a directory EFS for our mount point there and next 102
we need to run a sudo mount command which is quite long there so it makes 103
life a lot easier for us if we can just copy that so basically what it does it 104
amounts that mount target and it uses the domain name for that DFS service or 105
that EFS you share and that consists of the file system name and followed by EFS 106
dot and then the region and then dot amazon AWS com but again makes life a 107
lot easier for us now that the EFS system has created that for us or 108
automatically so what I'm going to do is just copy that and I'll use that when we 109
connect into our ec2 instance to run that mount command and ok so I've just 110
connected into that ec2 instance the first thing we need to do is we need to 111
make a directory for our EFS or we need to create a a mount point directory for 112
our EFS mount point so we do sudo and MKDIR EFS let's find the next 113
thing we need to do is we need to mount our EFS mount target to that EFS mount 114
point directory so we copy that command it was in the EFS console and we just 115
click enter and that will will start to happen for us ok so after certain amount 116
of time there we can see that it has created that so now going to CD into 117
that EFS here and just do a directory on it first 118
and we see that it's empty and what we'll do is we'll create a file to go in 119
there and see that's working so let's do touch 120
and then we just do a test file in there dot txt so there we can see that we 121
don't have permission so there is another layer of security for us with 122
the UNIX operating system so we can only create a fault if we have root access 123
there within our UNIX file system so again you use CHOWN or CHMOD to change 124
the permissions of that filesystem as you would do with any other Linux file 125
system this is not a course on Linux so if you need to find out about Linux do a 126
course on Linux but this is not a course on Linux you don't really need to know 127
Linux to pass the exams so what I'm going to do is sudo into this and then 128
do at you what I'll do is save myself typing so just do the same command as we 129
did before but we've sudo and so now to look at that we can see that that is 130
there now so there we have we've created an EFS share we've created mount 131
targets for that EFS share in availability zones we've then created an 132
ec2 instance and we've associated the security groups between the ec2 instance 133
and the EFS share so that they can communicate with each other and now we 134
have we have actually successfully mounted that mount target to our Linux 135
operating system so that's all we have to do for this lecture and I'll see you 136
in the next one