So we need to know how to use on premise instances for code deploy and the high level we need to configure
on each on premise instance that could deploy agents.
Register it and then we'll have the option to tie it on premise instances.
So you need to remember that tagging on premise instances is something that's only available for code
at this point.
And then we'll be able to deploy application revisions directly to the on premise instances.
So to do it to register an on premise instance the documentation gives us three ways and they can be
be grouped into two different kinds.
One is when we use an ATM user.
HRN to authenticate request.
And so we'll have to create an I.M. user for each on premise instance that we create.
So that works for a small number of instances.
The other option is to use an AM role.
HRN to authenticate request and they will use the s t s security token service.
And this is used to register large numbers of on premise instances but it is more painful to do so you
need to remember that the second one is definitely the most secure and you need to remember the steps
at a high level.
But for this hands on we'll do this one where we create an I am user Aaron and you'll see that's complicated
enough.
Now we'll use the register on premise instance API call.
We'll use the second tutorial then because it is the same API call that we'll use for it or for est.
Yes OK.
So let's go ahead and create and choose the second link.
So use the resistor on premise instance commands using an I.M. user Aaron to register and on premise
instance.
So the first thing we have to do is to create an on premise instance.
And because I expect you not you haven't on premise.
Instance what we'll do is that we'll create an easy to instance but we'll just call it on premise.
So this one isn't easy to instance a two to micro and we're not going to give it any role.
Okay.
Because we don't want to fake it.
We want to make sure it's like a VM that has nothing in us on it and we'll click on add storage tags
and for a name I will say it's on premise.
And for the environments maybe we'll call it on premise as well.
OK.
Security Group wise we'll just leave it as is for Port 22 and actually we'll just attach the one we
had from before and launch launch and yes I have that keep our lunch instances.
OK.
So that instance is the instance we will use and this is our fake on premise instance that we'll register
using this tutorial.
OK.
First thing we have to do is to create an AM user for the on premise instance.
So for this we need to create a resource.
Let's go to I am in here.
OK.
And we'll go ahead and create a user so add user and they recommend us to identify by a name that's
going to be explicit.
So we'll use the user name could the poor user on prem and remember you need to create one I am user
per on premise instance and for this we'll just give it programmatic access such as we have an access
key and a secret access key available to us next for permissions we'll look at what the permissions
are assigned and they recommend that we give it the S three permissions to read from it that makes a
lot of sense right.
We want are easy to our on premise instance to be able to fetch files from S3.
So as such we will go ahead and go to IEM and we will just attach directly policies and we'll go for
S3 read only.
OK next for tags we won't add any tech to it click on review and create that user.
So here is our user the code the poor user on prem and we have an access key idea and a secret access
key and I'll just keep this in this tab for now.
OK.
So we don't step two then we get the IAM credentials.
So this is what we have in this open tab so we'll keep it as is excellence and then we scroll down and
we need to add a configuration file to the on premise instance.
So we need to create a file named code deploy that's on premise document and we need to create it at
this location.
So let's do it.
We'll just create this file and so let's do it right now we've got two instances right click connect
using that easy to instance connect and connect to it
and we need to create this file called Easy TTC could deploy agent conf and then within it we need to
create this could deploy on premise.
So let's go here and click sudo nano and then the found them is going to be com start on premise document.
And I'm not even sure this will work.
Let's see you see the directory doesn't exist.
So we need to first create that directory.
So why don't we do pseudo make directory and then we'll just specify the entire directory.
So excellence accepts here I will do minus p so that it creates older directories in between.
So Major minus p excellence.
And now we are able to clear the screen and use the I know to create our file.
Okay.
Now within our file we need to specify the following.
So we'll paste this and there is the secret access key the access secret key and this is not real key
really really well for this unfortunately.
So let's try to use VDI.
See if that works better clear sudo and we'll use VDI for them and hopefully that works better so one
two three.
Then we have the access key idea so let's do it and we'll copy this one from AM.
So here is the one we want to copy.
Then we need to copy the secret access key so let's paste the one that we get from here and I'll just
copy this and paste it.
Then we need to have the I am user HRN So we need to get that user Aaron from here so let's close this.
Click on this user and here the full HRN So I'm going to paste this in here.
And finally we need the region and the region for me is you w 1.
Okay we got it.
I'm saving this file.
So this file has been written and this step is over.
Let's keep on going.
And now we need to install and configure the address you like.
So thankfully the ABC light is already installed on my easy to instance because it runs Amazon Linux
too.
But we need to configure it so we'll just do a double us.
So I'll clear the screen a W US configure and in here I will enter the same uh uh things we had from
before.
So the access code you except I don't have them.
So let me get them from that could the play agent file.
Okay so now we configure the access key is all the way here.
So let me just copy this entirely.
Okay.
The Secret Access Key is in here.
Excellence and the region name for default easy U.S. one and the other from it.
Jason Okay.
So now we've configured that as you like.
Good.
Now we need to set the of this region environment variable.
But I don't think we have to do it now because we've set up all these Virginia identifiers.
Then we need to install the code deploy agents.
So let's go and install that could deploy agents.
So all these commands right here we have to run them.
So I'll just paste them in here and this will run the installation for me.
And then finally we need to register the on premise instances with code deploy.
And for this we can use the address light and run this command right here.
So we'll call the register on premise instances which is this command right here.
So let's try it out.
So the trick here is that this command has to be run not from the easy to the on premise instance itself
but from our own CLIA.
So I'll have it here.
So we need to register the on premise instance we need to give an instance name we'll use this asset
tag whatever name they give it.
So it's it's a pretty funny name.
And then for the I am user Aaron we need to give the area that we've just created.
So let me get that from my web browser.
So in here I will say the I am engine console.
I'll copy this.
HRN pace this and then you make sure that it's the right profile I'm using.
So it must have ups and the region I mean is you w one they should do it.
Okay.
This command has succeeded.
So now my instance basically have registered on could deploy the instance named here and the associated
user.
Right.
Okay we're almost done.
And then we need to tag the on premise instance so we can either use the satellite or they could deploy
a console.
So let's go to could deploy and we can refresh this on premise instance page and here we go.
We can see that our instance has been registered in here.
And so I should be able if I click on it to add tags to it for example I could say that your name is
on premise and we get that many times.
Environments would be developments and submit this.
And here we go our instance has been tagged.
So this is excellent.
And then finally we can deploy application revisions to the on premise instance.
So we're ready to create a first deployment.
So how about we do this we'll create an in our application a new deployment group I'll call this one
on premise instances and it's in place it's going to use on premise instances.
And here we can use the environments to be development.
I think that's the one that I had.
Okay.
And then disable load balancing and click on Click on Create the Fleming group.
Here we go.
So we have created a deployment group for on premise instance.
And finally I should be able to create a deployment to it.
So on premise instances here is the last revision I want to publish to it and click on it deployments.
And here we go.
The deployment has been created and hopefully it's going to be successful.
So it's in progress.
It's installing the application on our instances.
And by the end of it it should be all ready to go.
So the thing I want you to remember out of it is that we have run a lot of different steps.
And the takeaway is that we have eleven steps.
But the major points in here is that we have to use an IBM user credential for each on premise instance.
So this is fine for a small number of on premise instances but it doesn't work at scale.
So at scale you need to look at this other tutorial and we're not going to do it.
It's a bit more tricky but you need to use an I am session Aaron and use the SDF service to refresh
temporary credentials.
And this allows for more automation but also for more security.
And so these are all the steps and we're not going to do them and it's just pretty painful to do.
But what I'm into remember out of this is that yes in this case we can use an I am role instead of I
am user to register our on premise instances.
The other thing I need to remember is that in code deploy when we went to our on premise instances and
we register them we had to tag them correctly.
So we had to add them for example a name tag an environment tag such as.
Now the deployment groups in could deploy could appropriately get them and understand how they worked.
So that's it.
And I'm not even sure this is actually working right now.
I probably missed a missed something which is probably fine is still in progress.
So it's probably not working very fine but I hope you get the idea of it.
I probably just messed up my configuration file to be honest.
But the idea is that for on premise instances we setup could deploy agents to use a specific I am user
register the instances target them appropriately and we should be ready to go.
So that's it.
I hope you liked it and I will see you in the next lecture.